Context commands
guideThe user and message context-menu command structures and builders, and what their trigger can read.
This page covers user command and message command: the structures behind Discord's right-click Apps menu, and their builder equivalents. You're assumed to have a bot named "my-bot" logged in and to have read Slash commands.
How context commands work
Right-clicking a user or a message in Discord opens an Apps submenu; each entry there is a context command. A user command structure answers a click on a user, a message command one answers a click on a message; both are models, exactly like slash command, with a trigger that runs once someone picks the entry.
user command Report user: trigger: reply with hidden "Reported %target user%" message command Quote this: trigger: reply with hidden "> %discord content of target message%"
A name is 1 to 32 characters and, unlike a slash command's, may contain spaces and capitals: "Report user" and "Quote this" are valid entries on Discord's menu. trigger is the only required entry.
Nothing reaches Discord until a script pushes it, the same way as a slash command: update the discord commands (all structured application commands) in event-guild from on guild ready sends every structure, context commands included. See Registering commands for register, unregister and the global/guild split. Context commands changed from v4 to v5 the same way slash commands did; see the admonition on Slash commands for what changed.
user command <(.+)$>Declares a user or message context-menu command (Apps > name when right-clicking a user or a message) and the trigger that runs when it is used: 'target user' / 'target message' give what was clicked.Entries
Entry | Default | Accepted values |
|---|---|---|
the header's own name | a section of | |
| (required) | a section of Skript code |
enabled for, disabled, nsfw, contexts, integration types, cooldown, cooldown scope and on cooldown work the same as on a slash command; see Command settings.
Inside the trigger
Value | Holds |
|---|---|
| the clicked user, in a |
| the clicked message, in a |
| the command's name |
| the invocation's context |
| the clicked message, same value as |
user command [receive[d]]Fired when someone click on a user application command. Use `used command` to get the command name and `target user` for the targeted user. Don't forget to either reply to the interaction. Defer doesn't work here.event
Message CommandEventsmessage command [receive[d]]Fired when someone click on a message application command. Use `used command` to get the command name and `target message` for the targeted message. Don't forget to either reply to the interaction. Defer doesn't work here.Building one instead
A context command builder is a plain object with a name and nothing else: no path, no trigger. Nothing reaches Discord until it's pushed, and a builder-declared command is answered in the generic event instead of running a trigger of its own.
on guild ready: set {_report} to a new user command named "Report user" register the discord command {_report} in event-guild on user command: if used user command is "Report user": reply with hidden "Reported %target user%"
on guild ready: set {_quote} to a new message command named "Quote this" register the discord command {_quote} in event-guild on message command: if used message command is "Quote this": reply with hidden "> %discord content of target message%"
Errors you may see
Message (console) | Cause | Fix |
|---|---|---|
A context command name is 1 to 32 characters long | the header's name is empty or too long | shorten or lengthen it to fit |
Unexpected entry 'x' in a context command. Known entries: name, enabled for, disabled, nsfw, contexts, integration types, cooldown, cooldown scope, on cooldown, trigger. | an entry name is misspelled, or belongs to | use one of the listed entries |