diff options
| author | 2021-09-06 15:54:33 +0200 | |
|---|---|---|
| committer | 2021-09-06 15:54:33 +0200 | |
| commit | 6b20bfba76e9f9b2c990929edfd5eeffb4555bd5 (patch) | |
| tree | 60b15b979530489af85b2465f1e2177795b899db | |
| parent | Make the bot auto-join threads (diff) | |
Silence: forbid threads from being silenced
| -rw-r--r-- | bot/exts/moderation/silence.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bot/exts/moderation/silence.py b/bot/exts/moderation/silence.py index 366d4e1f5..bf553f847 100644 --- a/bot/exts/moderation/silence.py +++ b/bot/exts/moderation/silence.py @@ -6,7 +6,7 @@ from datetime import datetime, timedelta, timezone from typing import Optional, OrderedDict, Union from async_rediscache import RedisCache -from discord import Guild, PermissionOverwrite, TextChannel, VoiceChannel +from discord import Guild, PermissionOverwrite, TextChannel, Thread, VoiceChannel from discord.ext import commands, tasks from discord.ext.commands import Context from discord.utils import MISSING @@ -182,6 +182,12 @@ class Silence(commands.Cog): channel_info = f"#{channel} ({channel.id})" log.debug(f"{ctx.author} is silencing channel {channel_info}.") + # Since threads don't have specific overrides, we cannot silence them individually. + # The parent channel has to be muted or the thread should be archived. + if isinstance(channel, Thread): + await ctx.send(":x: Threads cannot be silenced.") + return + if not await self._set_silence_overwrites(channel, kick=kick): log.info(f"Tried to silence channel {channel_info} but the channel was already silenced.") await self.send_message(MSG_SILENCE_FAIL, ctx.channel, channel, alert_target=False) |