Registers a new slash command. You may pass options and argument-type options to the config
paramter.
You must specify a handler to act on incoming command invocations.
Configuration for the command. Properties name
and description
must be present and valid.
An async function that takes two arguments, SlashCommandInteraction and a populated OptionsContainer. Called when the slash command is ran by a user.
Registers a new slash command with the intent to add sub-command and/or sub-command groups. You must pass a name and description in the first config object argument.
You must register sub-commands or sub-command groups with the appropriate methods on SlashCommandGroup.
Configuration for the command. Properties name
and description
must be present and valid.
Generated using TypeDoc
Discord Slash Commands
Slash commands offer a way to register commands with full auto-completion of options and discovery via the
/
menu.It's easy to register a slash command. Here's a quick example:
discord.interactions.commands.register({ name: 'ping', description: 'Replies with Pong!' }, async (interaction) => { await interaction.respond('Pong!'); });
Capturing command options, or arguments, is easy too. Here's an echo command example:
discord.interactions.commands.register({ name: 'echo', description: 'Replies and echos the original input.', options: (opt) => ({ input: opt.string('The text to echo.') }) }, async (interaction, { input }) => { await interaction.respond(`You said: ${input}`); });
Commands options have some configuration options. You can choose to make them optional, and even provide a list of pre-defined choices to some types!
See discord.interactions.commands.IOptionProviders for a list of option types and their configs.