Implement Slash Commands to Reduce Message Content Intent Reliance - #3453
Implement Slash Commands to Reduce Message Content Intent Reliance#3453lorenzo132 wants to merge 16 commits into
Conversation
This adds the ability to add attachments to snippets
As required and request per discord we have disabled prefix commands from being allowed. The bot now only accepts slashcommands or mention based commands.
There was a problem hiding this comment.
Pull request overview
This PR updates Modmail to v4.3.0 and introduces a slash-command compatibility layer (guild-scoped) to reduce reliance on the privileged message-content intent, alongside new support for snippet attachments stored in MongoDB GridFS.
Changes:
- Add guild-scoped slash command registration/refresh and disable legacy prefix commands by default (with intent gating).
- Add snippet attachment upload/download/delete via GridFS and wire snippet attachments into thread sending/logging.
- Update documentation/config examples and bump version references to v4.3.0.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates feature/command docs to slash-command + mention invocation model and adds command-interface guidance. |
| pyproject.toml | Bumps Poetry package version to 4.3.0. |
| core/thread.py | Adds snippet-attachment handling during send and logging. |
| core/slash_commands.py | Introduces a manager to expose legacy commands as guild-scoped application commands. |
| core/config.py | Adds config keys for command interfaces and snippet attachment size (MB) handling. |
| core/config_help.json | Documents snippet_attachment_max_size. |
| core/clients.py | Adds GridFS bucket support and snippet-attachment CRUD methods; extends logging API to accept attachment overrides. |
| cogs/utility.py | Switches user-facing examples/help formatting to support “/” display prefix and safer {prefix} substitution. |
| cogs/plugins.py | Refreshes slash command registry on plugin load/unload; updates installation examples. |
| cogs/modmail.py | Adds snippet attachment support (create/edit/remove) and adapts snippet display for new storage format. |
| CHANGELOG.md | Bumps changelog header to v4.3.0. |
| bot.py | Gates message-content intent behind prefix-enable flag; adds slash command sync/disable on connect; adds snippet attachment download wrapper. |
| app.json | Adds env var metadata for MODMAIL_GUILD_ID / USE_SLASH_COMMANDS / ENABLE_PREFIX_COMMANDS. |
| .env.example | Adds new env vars for slash/prefix command controls and optional MODMAIL_GUILD_ID. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.
Suppressed comments (4)
cogs/modmail.py:667
- Same as in
snippet_add: a negativesnippet_attachment_max_sizeresults in a negative byte limit and rejects all uploads. Clamp/validate before computingmax_size_bytes.
max_size_mb = self.bot.config.get("snippet_attachment_max_size")
max_size_bytes = max_size_mb * 1024 * 1024
core/slash_commands.py:103
REQUIRED_SLASH_PARAMETERSforces themessageoption to be required for/replyvariants even though the legacy commands accept an emptymsg(e.g.reply(..., msg: str = "")). This blocks valid slash use-cases like attachment-only replies/snippets.
REQUIRED_SLASH_PARAMETERS = {
"areply": {"msg"},
"fareply": {"msg"},
"fpareply": {"msg"},
"fpreply": {"msg"},
"freply": {"msg"},
"pareply": {"msg"},
"preply": {"msg"},
"reply": {"msg"},
}
cogs/modmail.py:410
snippet_attachment_max_sizecan be configured to a negative value, which makesmax_size_bytesnegative and causes every attachment to be rejected. Clamp to a non-negative size (or explicitly validate and error) before computing bytes.
This issue also appears on line 666 of the same file.
max_size_mb = self.bot.config.get("snippet_attachment_max_size")
max_size_bytes = max_size_mb * 1024 * 1024
cogs/utility.py:384
- "Checkout" is the noun/verb for completing a purchase; here the intended phrase is "Check out" (verb) meaning “take a look at”.
"Checkout the people who supported Modmail with command "
f"`{self.bot.command_display_prefix}sponsors`!"
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
cogs/utility.py:385
- Grammar: "Checkout" should be "Check out" in this user-facing help text.
value=(
"Checkout the people who supported Modmail with command "
f"`{self.bot.command_display_prefix}sponsors`!"
),
| # Handle optional attachment | ||
| file_id = None | ||
| attachment_info = None | ||
| if ctx.message.attachments: | ||
| attachment = ctx.message.attachments[0] |
No description provided.