command
Call Signature
Section titled “Call Signature”command<
O>(config,run):Command<O>
Defined in: command.ts:32
Declares a slash command and the handler that answers it. To split a command into subcommands,
such as /config get and /config set, pass subcommands instead of options and run: a list
of commands made with command(). A subcommand that has subcommands of its own becomes a group,
such as /config role add. Discord allows one group level only.
Type Parameters
Section titled “Type Parameters”O extends Options = never
Parameters
Section titled “Parameters”config
Section titled “config”object & Access
What Discord shows for the command.
(c) => Response | Promise<Response>
Answers the command. It gets the interaction, the typed option values, reply
for an answer within 3 seconds and defer for work that takes longer. Pass
{ ephemeral: true } to either so only the user who ran the command sees the answer, buttons
to add buttons and embeds to add embeds. Messages ping nobody, even for @everyone or <@id>
in the text. To ping, pass allowedMentions, such as { users: [id] } or { parse: ['roles'] }. The work of defer returns the text, or
{ content, buttons, embeds }.
To send more after the first answer, call c.after(work) before you return it. work runs once
Discord has the answer, and can call c.followUp(text, options) for a new message,
c.editReply(text, options) and c.deleteReply(). Each returns an Error if Discord refuses.
The work of defer can call them too. Buttons, select menus, modals and context menus have them.
Returns
Section titled “Returns”Command<O>
The command, for the commands of bot.
Example
Section titled “Example”const greet = command( { name: 'greet', description: 'Say hi', options: { name: option('string', { description: 'Who', required: true }) } }, (c) => c.reply(`hi ${c.options.name}`),);Call Signature
Section titled “Call Signature”command(
config):Command
Defined in: command.ts:36
Declares a slash command and the handler that answers it. To split a command into subcommands,
such as /config get and /config set, pass subcommands instead of options and run: a list
of commands made with command(). A subcommand that has subcommands of its own becomes a group,
such as /config role add. Discord allows one group level only.
Parameters
Section titled “Parameters”config
Section titled “config”object & Access
What Discord shows for the command.
Returns
Section titled “Returns”The command, for the commands of bot.
Example
Section titled “Example”const greet = command( { name: 'greet', description: 'Say hi', options: { name: option('string', { description: 'Who', required: true }) } }, (c) => c.reply(`hi ${c.options.name}`),);