Add auto report of deleted messages#740
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds automatic reporting of moderator-deleted messages to committee channels by correlating message deletion events with audit log entries, and enables the required Discord intent to access message content.
Changes:
- Enable
Intents.message_contenton bot startup to allow access to message content for deletion reporting. - Add a new
ModerationCogthat listens for message deletions and attempts to attribute them to a deleter via audit logs, then forwards details to the committee channel. - Register the new cog in
cogs/__init__.pyso it’s loaded on startup.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| main.py | Enables message_content intent needed for deletion content reporting. |
| cogs/moderation.py | New cog implementing deletion tracking + committee reporting logic. |
| cogs/init.py | Adds ModerationCog import, export, and startup registration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @TeXBotBaseCog.listener() | ||
| @capture_guild_does_not_exist_error | ||
| async def on_message_delete(self, message: discord.Message) -> None: | ||
| """Listen for message deletions.""" | ||
| self.most_recently_deleted_message = message | ||
|
|
There was a problem hiding this comment.
most_recently_deleted_message only tracks a single deletion and is never cleared/expired. If a user deletes their own message (no audit-log entry), this cached message can later be incorrectly paired with a moderator message_delete audit-log entry for the same author/channel, causing the bot to report the wrong content (and miss the real deleted message). Consider storing a short-lived queue keyed by (channel_id, author_id) with deletion timestamps (and clearing on successful match), rather than a single global reference.
| intents=discord.Intents.default() | discord.Intents.members | ||
| intents=discord.Intents.default() | ||
| | discord.Intents.members | ||
| | discord.Intents.message_content |
There was a problem hiding this comment.
This is the biggest issue here. We have purposefully limited the privileges of TeX-Bot to not have access to read members messages and this is a departure from this. Making this change requires a vote of approval from CSS committee.
There was a problem hiding this comment.
Committee discussed and approved this change
Send a quoted message to committee channels when a message is deleted.
Under the following conditions:
This feature is designed to make sure that messages deleted as part of moderation action are retained; in the event that the committee member forgets to do it manually.