Context Commands
Context commands are a form of application command, triggered by users via a right-click/tap-and-hold menu in their Discord client. Unlike other types of command, context commands do not take arguments — instead, they're provided with whatever the user was targeting when they opened the menu.
When registered by your bot, context commands are visible in a menu named Apps. There are two types of context command — message commands and user commands. They have identical APIs, aside from the target data supplied to them by Discord.
Extension API
The following APIs are available on the Extension
type, which you can use to define your context commands and modify their behavior.
Builders
Name | Receiver | Description |
---|---|---|
Checks | ||
|
| Register a check that must pass for the |
|
| Register a check that must pass for the |
Commands | ||
|
| Register an ephemeral message command. This builder function optionally takes the constructor of a modal form class as the first argument, representing the modal form to display and await input for when the command is executed. |
|
| Register an ephemeral user command. This builder function optionally takes the constructor of a modal form class as the first argument, representing the modal form to display and await input for when the command is executed. |
|
| Register a public message command. This builder function optionally takes the constructor of a modal form class as the first argument, representing the modal form to display and await input for when the command is executed. |
|
| Register a public user command. This builder function optionally takes the constructor of a modal form class as the first argument,s representing the modal form to display and await input for when the command is executed. |
Message Commands
Message commands are registered by calling the relevant functions in your extension's setup
function:
ephemeralMessageCommand
for message commands that respond ephemerally.publicMessageCommand
for message commands that respond publicly.
Message commands have an identical API to that which is provided by Application Commands, but message command context objects provide a targetMessages
property. This property corresponds with the Discord API, which provides a list that contains the message that was being targeted when the command was executed.
Message commands support modal forms, as described in the commands overview page.
User Commands
User commands are registered by calling the relevant functions in your extension's setup
function:
ephemeralUserCommand
for user commands that respond ephemerally.publicUserCommand
for user commands that respond publicly.
User commands have an identical API to that which is provided by Application Commands, but user command context objects provide a targetUsers
property. This property corresponds with the Discord API, which provides a list that contains the Discord user that was being targeted when the command was executed.
User commands support modal forms, as described in the commands overview page.