Results

Namespace

Type

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.

Index

Type aliases

HandlerFunction

HandlerFunction<T>: function

Type parameters

  • T

Type declaration

OptionType

OptionType: string | number | boolean | GuildMember | GuildChannel | Role | null

OptionsFactory

OptionsFactory<T>: function

Type parameters

Type declaration

ResolvedOptions

ResolvedOptions: object

Type declaration

ResponseMessageOptions

ResponseMessageOptions: IResponseMessageOptions & object | IResponseMessageOptions & object

Functions

register

  • register<T>(config: ICommandConfig<T>, handler: HandlerFunction<T>): SlashCommand<T>
  • 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.

    Type parameters

    Parameters

    • config: ICommandConfig<T>

      Configuration for the command. Properties name and description must be present and valid.

    • handler: HandlerFunction<T>

      An async function that takes two arguments, SlashCommandInteraction and a populated OptionsContainer. Called when the slash command is ran by a user.

    Returns SlashCommand<T>

registerGroup

  • registerGroup(config: ICommandGroupConfig): SlashCommandGroup
  • 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.

    Parameters

    • config: ICommandGroupConfig

      Configuration for the command. Properties name and description must be present and valid.

    Returns SlashCommandGroup

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc