aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/moderation/modlog.py
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts/moderation/modlog.py')
-rw-r--r--bot/exts/moderation/modlog.py38
1 files changed, 9 insertions, 29 deletions
diff --git a/bot/exts/moderation/modlog.py b/bot/exts/moderation/modlog.py
index 511f05c50..47a21753c 100644
--- a/bot/exts/moderation/modlog.py
+++ b/bot/exts/moderation/modlog.py
@@ -13,7 +13,7 @@ from discord.ext.commands import Cog, Context
from discord.utils import escape_markdown, format_dt, snowflake_time
from bot.bot import Bot
-from bot.constants import Categories, Channels, Colours, Emojis, Event, Guild as GuildConstant, Icons, Roles
+from bot.constants import Channels, Colours, Emojis, Event, Guild as GuildConstant, Icons, Roles
from bot.log import get_logger
from bot.utils import time
from bot.utils.messages import format_user, upload_log
@@ -164,12 +164,6 @@ class ModLog(Cog, name="ModLog"):
self._ignored[Event.guild_channel_update].remove(before.id)
return
- # Two channel updates are sent for a single edit: 1 for topic and 1 for category change.
- # TODO: remove once support is added for ignoring multiple occurrences for the same channel.
- help_categories = (Categories.help_available, Categories.help_dormant, Categories.help_in_use)
- if after.category and after.category.id in help_categories:
- return
-
diff = DeepDiff(before, after)
changes = []
done = []
@@ -495,7 +489,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.
@@ -504,7 +498,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:
@@ -787,13 +782,14 @@ class ModLog(Cog, name="ModLog"):
(
f"Thread {after.mention} ({after.name}, `{after.id}`) from {after.parent.mention} "
f"(`{after.parent.id}`) was {action}"
- )
+ ),
+ channel_id=Channels.message_log,
)
@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
@@ -804,24 +800,8 @@ class ModLog(Cog, name="ModLog"):
(
f"Thread {thread.mention} ({thread.name}, `{thread.id}`) from {thread.parent.mention} "
f"(`{thread.parent.id}`) deleted"
- )
- )
-
- @Cog.listener()
- async def on_thread_create(self, thread: Thread) -> None:
- """Log thread creation."""
- if self.is_channel_ignored(thread.id):
- log.trace("Ignoring creation of thread %s (%d)", thread.mention, thread.id)
- return
-
- await self.send_log_message(
- Icons.hash_green,
- Colours.soft_green,
- "Thread created",
- (
- f"Thread {thread.mention} ({thread.name}, `{thread.id}`) from {thread.parent.mention} "
- f"(`{thread.parent.id}`) created"
- )
+ ),
+ channel_id=Channels.message_log,
)
@Cog.listener()