diff options
Diffstat (limited to 'bot/exts/moderation/modlog.py')
| -rw-r--r-- | bot/exts/moderation/modlog.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/bot/exts/moderation/modlog.py b/bot/exts/moderation/modlog.py index 3e19083ac..375956dd3 100644 --- a/bot/exts/moderation/modlog.py +++ b/bot/exts/moderation/modlog.py @@ -527,17 +527,28 @@ class ModLog(Cog, name="ModLog"): return self.is_raw_message_blacklisted(message.guild.id, message.channel.id) - def is_raw_message_blacklisted(self, guild_id: t.Optional[int], channel_id: int) -> bool: - """Return true if the message constructed from raw parameter is in a blacklisted thread or channel.""" - # Ignore DMs or messages outside of the main guild - if not guild_id or guild_id != GuildConstant.id: - return True - + def is_raw_message_blacklisted(self, channel_id: int) -> bool: + """ + Return true if the channel, or parent channel in the case of threads, passed should be ignored by modlog. + + Currently ignored channels are: + 1. Channels not in the guild we care about (constants.Guild.id). + 2. Channels that mods do not have view permissions to + 3. Channels in constants.Guild.modlog_blacklist + """ channel = self.bot.get_channel(channel_id) - # Look at the parent channel of a thread + # Ignore not found channels, DMs, and messages outside of the main guild. + if not channel or channel.guild and channel.guild.id != GuildConstant.id: + return True + + # Look at the parent channel of a thread. if isinstance(channel, Thread): - return channel.parent.id in GuildConstant.modlog_blacklist + channel = channel.parent + + # Mod team doesn't have view permission to the channel. + if not channel.permissions_for(channel.guild.get_role(Roles.mod_team)).view_channel: + return True return channel.id in GuildConstant.modlog_blacklist |