Skip to content

SlashCommandHandler

Defined in: handlers/SlashCommandHandler.ts:22

Handler for chat input commands with optional autocomplete support

  • SlashCommandBuilder

Context extends BaseInteractionContext = BaseInteractionContext

new SlashCommandHandler<Context>(): SlashCommandHandler<Context>

SlashCommandHandler<Context>

SlashCommandBuilder.constructor

readonly guildIds: Set<string>

Defined in: handlers/SlashCommandHandler.ts:29

Set of guild IDs where this command is registered (empty for global commands)


readonly handlerType: "slash" = "slash"

Defined in: handlers/SlashCommandHandler.ts:23

addAttachmentOption(input): this

Defined in: handlers/SlashCommandHandler.ts:131

Adds an attachment option.

SlashCommandAttachmentOption | ((builder) => SlashCommandAttachmentOption)

A function that returns an option builder or an already built builder

this

SlashCommandBuilder.addAttachmentOption


addAutocompleteHandler(handler): SlashCommandHandler<Context>

Defined in: handlers/SlashCommandHandler.ts:80

Adds the autocomplete handler function.

(interaction) => any

The function to handle the autocomplete interaction

SlashCommandHandler<Context>

The current SlashCommandHandler instance


addBooleanOption(input): this

Defined in: handlers/SlashCommandHandler.ts:111

Override option/subcommand adders so they return this (the handler), preserving chaining when options/subcommands are added.

SlashCommandBooleanOption | ((builder) => SlashCommandBooleanOption)

this

SlashCommandBuilder.addBooleanOption


addChannelOption(input): this

Defined in: handlers/SlashCommandHandler.ts:121

Adds a channel option.

SlashCommandChannelOption | ((builder) => SlashCommandChannelOption)

A function that returns an option builder or an already built builder

this

SlashCommandBuilder.addChannelOption


addGuildIds(…guildIds): this

Defined in: handlers/SlashCommandHandler.ts:46

Adds one or more guild IDs to guildIds, making this a guild-scoped command.

…string[]

this


addHandler(handler): SlashCommandHandler<Context>

Defined in: handlers/SlashCommandHandler.ts:67

Adds the command handler function.

(interaction) => any

The function to handle the command interaction

SlashCommandHandler<Context>

The current SlashCommandHandler instance


addIntegerOption(input): this

Defined in: handlers/SlashCommandHandler.ts:150

Adds an integer option.

SlashCommandIntegerOption | ((builder) => SlashCommandIntegerOption)

A function that returns an option builder or an already built builder

this

SlashCommandBuilder.addIntegerOption


addMentionableOption(input): this

Defined in: handlers/SlashCommandHandler.ts:138

Adds a mentionable option.

SlashCommandMentionableOption | ((builder) => SlashCommandMentionableOption)

A function that returns an option builder or an already built builder

this

SlashCommandBuilder.addMentionableOption


addNumberOption(input): this

Defined in: handlers/SlashCommandHandler.ts:155

Adds a number option.

SlashCommandNumberOption | ((builder) => SlashCommandNumberOption)

A function that returns an option builder or an already built builder

this

SlashCommandBuilder.addNumberOption


addRoleOption(input): this

Defined in: handlers/SlashCommandHandler.ts:126

Adds a role option.

SlashCommandRoleOption | ((builder) => SlashCommandRoleOption)

A function that returns an option builder or an already built builder

this

SlashCommandBuilder.addRoleOption


addStringOption(input): this

Defined in: handlers/SlashCommandHandler.ts:145

Adds a string option.

SlashCommandStringOption | ((builder) => SlashCommandStringOption)

A function that returns an option builder or an already built builder

this

SlashCommandBuilder.addStringOption


addSubcommand(input): this

Defined in: handlers/SlashCommandHandler.ts:160

Adds a new subcommand to this command.

SlashCommandSubcommandBuilder | ((sub) => SlashCommandSubcommandBuilder)

A function that returns a subcommand builder or an already built builder

this

SlashCommandBuilder.addSubcommand


addSubcommandGroup(input): this

Defined in: handlers/SlashCommandHandler.ts:167

Adds a new subcommand group to this command.

SlashCommandSubcommandGroupBuilder | ((group) => SlashCommandSubcommandGroupBuilder)

A function that returns a subcommand group builder or an already built builder

this

SlashCommandBuilder.addSubcommandGroup


addUserOption(input): this

Defined in: handlers/SlashCommandHandler.ts:116

Adds a user option.

SlashCommandUserOption | ((builder) => SlashCommandUserOption)

A function that returns an option builder or an already built builder

this

SlashCommandBuilder.addUserOption


execute(interaction): Promise<void>

Defined in: handlers/SlashCommandHandler.ts:90

Executes the command handler

ChatInputCommandInteraction<Context>

Promise<void>


executeAutocomplete(interaction): Promise<void>

Defined in: handlers/SlashCommandHandler.ts:100

Executes the autocomplete handler if it exists

AutocompleteInteraction<Context>

Promise<void>


isGuildCommand(): boolean

Defined in: handlers/SlashCommandHandler.ts:32

Whether this command is registered per-guild (true) or globally (false, the default).

boolean


removeGuildIds(…guildIds): this

Defined in: handlers/SlashCommandHandler.ts:54

Removes one or more guild IDs from guildIds.

…string[]

this


setGuildIds(guildIds): this

Defined in: handlers/SlashCommandHandler.ts:37

Replaces guildIds with the given list, making this a guild-scoped command.

string[]

this