aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-10-08 12:25:41 -0700
committerGravatar MarkKoz <[email protected]>2020-10-08 12:25:41 -0700
commitd0c3990e8eb9e68537c05ec58594abdf5c4cee9e (patch)
treebd88f642fcdc756dac4df54d208459437b6df6d6
parentSilence tests: fix unawaited coro warnings (diff)
Silence: add to notifier when indefinite rather than temporary
Accidentally swapped the logic in a previous commit during a refactor.
-rw-r--r--bot/cogs/moderation/silence.py2
-rw-r--r--tests/bot/cogs/moderation/test_silence.py12
2 files changed, 7 insertions, 7 deletions
diff --git a/bot/cogs/moderation/silence.py b/bot/cogs/moderation/silence.py
index 178dee06f..95706392a 100644
--- a/bot/cogs/moderation/silence.py
+++ b/bot/cogs/moderation/silence.py
@@ -116,10 +116,10 @@ class Silence(commands.Cog):
await self._schedule_unsilence(ctx, duration)
if duration is None:
+ self.notifier.add_channel(ctx.channel)
log.info(f"Silenced {channel_info} indefinitely.")
await ctx.send(MSG_SILENCE_PERMANENT)
else:
- self.notifier.add_channel(ctx.channel)
log.info(f"Silenced {channel_info} for {duration} minute(s).")
await ctx.send(MSG_SILENCE_SUCCESS.format(duration=duration))
diff --git a/tests/bot/cogs/moderation/test_silence.py b/tests/bot/cogs/moderation/test_silence.py
index 6a8db72e8..50d8419ac 100644
--- a/tests/bot/cogs/moderation/test_silence.py
+++ b/tests/bot/cogs/moderation/test_silence.py
@@ -296,17 +296,17 @@ class SilenceTests(unittest.IsolatedAsyncioTestCase):
self.assertDictEqual(prev_overwrite_dict, new_overwrite_dict)
- async def test_temp_added_to_notifier(self):
- """Channel was added to notifier if a duration was set for the silence."""
+ async def test_temp_not_added_to_notifier(self):
+ """Channel was not added to notifier if a duration was set for the silence."""
with mock.patch.object(self.cog, "_silence_overwrites", return_value=True):
await self.cog.silence.callback(self.cog, MockContext(), 15)
- self.cog.notifier.add_channel.assert_called_once()
+ self.cog.notifier.add_channel.assert_not_called()
- async def test_indefinite_not_added_to_notifier(self):
- """Channel was not added to notifier if a duration was not set for the silence."""
+ async def test_indefinite_added_to_notifier(self):
+ """Channel was added to notifier if a duration was not set for the silence."""
with mock.patch.object(self.cog, "_silence_overwrites", return_value=True):
await self.cog.silence.callback(self.cog, MockContext(), None)
- self.cog.notifier.add_channel.assert_not_called()
+ self.cog.notifier.add_channel.assert_called_once()
async def test_silenced_not_added_to_notifier(self):
"""Channel was not added to the notifier if it was already silenced."""