aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-03-15 17:56:24 +0100
committerGravatar Numerlor <[email protected]>2020-03-15 17:56:24 +0100
commit678f8552fddcaca65289f6da0bcaa0c7b5ac14d1 (patch)
treed132f13ab91382db17ea0d4196d09f7620f7ef62
parentChange BadArgument error wording. (diff)
Pass kwargs directly instead of a PermissionOverwrite.
The `set_permissions` method creates a `PermissionOverwrite` from kwargs internally, so we can skip creating it ourselves and unpack the dict directly into kwargs.
-rw-r--r--bot/cogs/moderation/silence.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/bot/cogs/moderation/silence.py b/bot/cogs/moderation/silence.py
index 5df1fbbc0..3d6ca8867 100644
--- a/bot/cogs/moderation/silence.py
+++ b/bot/cogs/moderation/silence.py
@@ -3,7 +3,7 @@ import logging
from contextlib import suppress
from typing import Optional
-from discord import PermissionOverwrite, TextChannel
+from discord import TextChannel
from discord.ext import commands, tasks
from discord.ext.commands import Context
@@ -114,10 +114,7 @@ class Silence(commands.Cog):
if current_overwrite.send_messages is False:
log.info(f"Tried to silence channel #{channel} ({channel.id}) but the channel was already silenced.")
return False
- await channel.set_permissions(
- self._verified_role,
- overwrite=PermissionOverwrite(**dict(current_overwrite, send_messages=False))
- )
+ await channel.set_permissions(self._verified_role, **dict(current_overwrite, send_messages=False))
self.muted_channels.add(channel)
if persistent:
log.info(f"Silenced #{channel} ({channel.id}) indefinitely.")
@@ -136,10 +133,7 @@ class Silence(commands.Cog):
"""
current_overwrite = channel.overwrites_for(self._verified_role)
if current_overwrite.send_messages is False:
- await channel.set_permissions(
- self._verified_role,
- overwrite=PermissionOverwrite(**dict(current_overwrite, send_messages=True))
- )
+ 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):