aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2020-11-25 09:05:29 +0300
committerGravatar GitHub <[email protected]>2020-11-25 09:05:29 +0300
commit7c87400c05276534bbeb155a569d9c88ae83f0c6 (patch)
treed3f2ecbae7b60369daaec68f569a39df7a76d605
parentReduces IsInstance Calls Where Possible (diff)
Refactors Send Message Function
Refactors the send message utility function to make it more legible and reduce unnecessary calls. Co-authored-by: Mark <[email protected]>
-rw-r--r--bot/exts/moderation/silence.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/bot/exts/moderation/silence.py b/bot/exts/moderation/silence.py
index 69ad1f45e..eaaf7e69b 100644
--- a/bot/exts/moderation/silence.py
+++ b/bot/exts/moderation/silence.py
@@ -123,12 +123,6 @@ class Silence(commands.Cog):
) -> None:
"""Helper function to send message confirmation to `source_channel`, and notification to `target_channel`."""
# Get TextChannel connected to VoiceChannel if channel is of type voice
- voice_chat = None
- target_is_voice_channel = isinstance(target_channel, VoiceChannel)
-
- if target_is_voice_channel:
- voice_chat = await self._get_related_text_channel(target_channel)
-
# Reply to invocation channel
source_reply = message
if source_channel != target_channel:
@@ -136,12 +130,12 @@ class Silence(commands.Cog):
await source_channel.send(source_reply)
# Reply to target channel
- if alert_target and source_channel not in [target_channel, voice_chat]:
- if target_is_voice_channel:
- if voice_chat is not None:
+ if alert_target:
+ if isinstance(target_channel, VoiceChannel):
+ voice_chat = await self._get_related_text_channel(target_channel)
+ if voice_chat and source_channel != voice_chat:
await voice_chat.send(message.replace("current channel", target_channel.mention))
-
- else:
+ elif source_channel != target_channel:
await target_channel.send(message)
@commands.command(aliases=("hush",))