aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2023-01-03 11:38:21 +0000
committerGravatar Chris Lovering <[email protected]>2023-01-03 11:38:21 +0000
commit95fd2df1513aa3088d396dc837bc3be67234a223 (patch)
tree73bca2a9995f0f0cfd9accb58eb3d72abd3064dc
parentLink previous nomination threads to a user nomination's history (#2373) (diff)
Allow passing ful channel objects to check if the channel is ignored
This means that the is_channel_ignored fucntion can be used with on_*_delete events that have the channel object, but can't be retreived fromthe cache by the is_channel_ignored function
-rw-r--r--bot/exts/moderation/modlog.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/exts/moderation/modlog.py b/bot/exts/moderation/modlog.py
index eeaf69139..2c94d1af8 100644
--- a/bot/exts/moderation/modlog.py
+++ b/bot/exts/moderation/modlog.py
@@ -534,7 +534,7 @@ class ModLog(Cog, name="ModLog"):
return self.is_channel_ignored(message.channel.id)
- def is_channel_ignored(self, channel_id: int) -> bool:
+ def is_channel_ignored(self, channel: int | GuildChannel | Thread) -> bool:
"""
Return true if the channel, or parent channel in the case of threads, passed should be ignored by modlog.
@@ -543,7 +543,8 @@ class ModLog(Cog, name="ModLog"):
2. Channels that mods do not have view permissions to
3. Channels in constants.Guild.modlog_blacklist
"""
- channel = self.bot.get_channel(channel_id)
+ if isinstance(channel, int):
+ channel = self.bot.get_channel(channel)
# Ignore not found channels, DMs, and messages outside of the main guild.
if not channel or channel.guild is None or channel.guild.id != GuildConstant.id:
@@ -833,7 +834,7 @@ class ModLog(Cog, name="ModLog"):
@Cog.listener()
async def on_thread_delete(self, thread: Thread) -> None:
"""Log thread deletion."""
- if self.is_channel_ignored(thread.id):
+ if self.is_channel_ignored(thread):
log.trace("Ignoring deletion of thread %s (%d)", thread.mention, thread.id)
return