aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-03-17 20:10:50 +0100
committerGravatar Numerlor <[email protected]>2020-03-17 20:10:50 +0100
commitc68b943708eaca110ddfa6121872513a422bbef4 (patch)
tree1c6fc06017c99c38478f621a31a232b5191afaf7
parentAdd docstring to test. (diff)
Use set `discard` instead of `remove`.
Discard ignores non present values, allowing us to skip the KeyError suppress.
-rw-r--r--bot/cogs/moderation/silence.py3
-rw-r--r--tests/bot/cogs/moderation/test_silence.py2
2 files changed, 2 insertions, 3 deletions
diff --git a/bot/cogs/moderation/silence.py b/bot/cogs/moderation/silence.py
index 1523baf11..a1446089e 100644
--- a/bot/cogs/moderation/silence.py
+++ b/bot/cogs/moderation/silence.py
@@ -141,8 +141,7 @@ class Silence(commands.Cog):
await channel.set_permissions(self._verified_role, **dict(current_overwrite, send_messages=True))
log.info(f"Unsilenced channel #{channel} ({channel.id}).")
self.notifier.remove_channel(channel)
- with suppress(KeyError):
- self.muted_channels.remove(channel)
+ self.muted_channels.discard(channel)
return True
log.info(f"Tried to unsilence channel #{channel} ({channel.id}) but the channel was not silenced.")
return False
diff --git a/tests/bot/cogs/moderation/test_silence.py b/tests/bot/cogs/moderation/test_silence.py
index 71541086d..eee020455 100644
--- a/tests/bot/cogs/moderation/test_silence.py
+++ b/tests/bot/cogs/moderation/test_silence.py
@@ -195,7 +195,7 @@ class SilenceTests(unittest.IsolatedAsyncioTestCase):
channel = MockTextChannel(overwrites_for=Mock(return_value=perm_overwrite))
with mock.patch.object(self.cog, "muted_channels") as muted_channels:
await self.cog._unsilence(channel)
- muted_channels.remove.assert_called_once_with(channel)
+ muted_channels.discard.assert_called_once_with(channel)
@mock.patch("bot.cogs.moderation.silence.asyncio")
@mock.patch.object(Silence, "_mod_alerts_channel", create=True)