SlashCommandHandler
Class: SlashCommandHandler<Context>
Section titled “Class: SlashCommandHandler<Context>”Defined in: handlers/SlashCommandHandler.ts:22
Handler for chat input commands with optional autocomplete support
Extends
Section titled “Extends”SlashCommandBuilder
Type Parameters
Section titled “Type Parameters”Context
Section titled “Context”Context extends BaseInteractionContext = BaseInteractionContext
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SlashCommandHandler<
Context>():SlashCommandHandler<Context>
Returns
Section titled “Returns”SlashCommandHandler<Context>
Inherited from
Section titled “Inherited from”SlashCommandBuilder.constructor
Properties
Section titled “Properties”guildIds
Section titled “guildIds”
readonlyguildIds:Set<string>
Defined in: handlers/SlashCommandHandler.ts:29
Set of guild IDs where this command is registered (empty for global commands)
handlerType
Section titled “handlerType”
readonlyhandlerType:"slash"="slash"
Defined in: handlers/SlashCommandHandler.ts:23
Methods
Section titled “Methods”addAttachmentOption()
Section titled “addAttachmentOption()”addAttachmentOption(
input):this
Defined in: handlers/SlashCommandHandler.ts:131
Adds an attachment option.
Parameters
Section titled “Parameters”SlashCommandAttachmentOption | ((builder) => SlashCommandAttachmentOption)
A function that returns an option builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addAttachmentOption
addAutocompleteHandler()
Section titled “addAutocompleteHandler()”addAutocompleteHandler(
handler):SlashCommandHandler<Context>
Defined in: handlers/SlashCommandHandler.ts:80
Adds the autocomplete handler function.
Parameters
Section titled “Parameters”handler
Section titled “handler”(interaction) => any
The function to handle the autocomplete interaction
Returns
Section titled “Returns”SlashCommandHandler<Context>
The current SlashCommandHandler instance
addBooleanOption()
Section titled “addBooleanOption()”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.
Parameters
Section titled “Parameters”SlashCommandBooleanOption | ((builder) => SlashCommandBooleanOption)
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addBooleanOption
addChannelOption()
Section titled “addChannelOption()”addChannelOption(
input):this
Defined in: handlers/SlashCommandHandler.ts:121
Adds a channel option.
Parameters
Section titled “Parameters”SlashCommandChannelOption | ((builder) => SlashCommandChannelOption)
A function that returns an option builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addChannelOption
addGuildIds()
Section titled “addGuildIds()”addGuildIds(…
guildIds):this
Defined in: handlers/SlashCommandHandler.ts:46
Adds one or more guild IDs to guildIds, making this a guild-scoped command.
Parameters
Section titled “Parameters”guildIds
Section titled “guildIds”…string[]
Returns
Section titled “Returns”this
addHandler()
Section titled “addHandler()”addHandler(
handler):SlashCommandHandler<Context>
Defined in: handlers/SlashCommandHandler.ts:67
Adds the command handler function.
Parameters
Section titled “Parameters”handler
Section titled “handler”(interaction) => any
The function to handle the command interaction
Returns
Section titled “Returns”SlashCommandHandler<Context>
The current SlashCommandHandler instance
addIntegerOption()
Section titled “addIntegerOption()”addIntegerOption(
input):this
Defined in: handlers/SlashCommandHandler.ts:150
Adds an integer option.
Parameters
Section titled “Parameters”SlashCommandIntegerOption | ((builder) => SlashCommandIntegerOption)
A function that returns an option builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addIntegerOption
addMentionableOption()
Section titled “addMentionableOption()”addMentionableOption(
input):this
Defined in: handlers/SlashCommandHandler.ts:138
Adds a mentionable option.
Parameters
Section titled “Parameters”SlashCommandMentionableOption | ((builder) => SlashCommandMentionableOption)
A function that returns an option builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addMentionableOption
addNumberOption()
Section titled “addNumberOption()”addNumberOption(
input):this
Defined in: handlers/SlashCommandHandler.ts:155
Adds a number option.
Parameters
Section titled “Parameters”SlashCommandNumberOption | ((builder) => SlashCommandNumberOption)
A function that returns an option builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addNumberOption
addRoleOption()
Section titled “addRoleOption()”addRoleOption(
input):this
Defined in: handlers/SlashCommandHandler.ts:126
Adds a role option.
Parameters
Section titled “Parameters”SlashCommandRoleOption | ((builder) => SlashCommandRoleOption)
A function that returns an option builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addRoleOption
addStringOption()
Section titled “addStringOption()”addStringOption(
input):this
Defined in: handlers/SlashCommandHandler.ts:145
Adds a string option.
Parameters
Section titled “Parameters”SlashCommandStringOption | ((builder) => SlashCommandStringOption)
A function that returns an option builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addStringOption
addSubcommand()
Section titled “addSubcommand()”addSubcommand(
input):this
Defined in: handlers/SlashCommandHandler.ts:160
Adds a new subcommand to this command.
Parameters
Section titled “Parameters”SlashCommandSubcommandBuilder | ((sub) => SlashCommandSubcommandBuilder)
A function that returns a subcommand builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addSubcommand
addSubcommandGroup()
Section titled “addSubcommandGroup()”addSubcommandGroup(
input):this
Defined in: handlers/SlashCommandHandler.ts:167
Adds a new subcommand group to this command.
Parameters
Section titled “Parameters”SlashCommandSubcommandGroupBuilder | ((group) => SlashCommandSubcommandGroupBuilder)
A function that returns a subcommand group builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addSubcommandGroup
addUserOption()
Section titled “addUserOption()”addUserOption(
input):this
Defined in: handlers/SlashCommandHandler.ts:116
Adds a user option.
Parameters
Section titled “Parameters”SlashCommandUserOption | ((builder) => SlashCommandUserOption)
A function that returns an option builder or an already built builder
Returns
Section titled “Returns”this
Overrides
Section titled “Overrides”SlashCommandBuilder.addUserOption
execute()
Section titled “execute()”execute(
interaction):Promise<void>
Defined in: handlers/SlashCommandHandler.ts:90
Executes the command handler
Parameters
Section titled “Parameters”interaction
Section titled “interaction”ChatInputCommandInteraction<Context>
Returns
Section titled “Returns”Promise<void>
executeAutocomplete()
Section titled “executeAutocomplete()”executeAutocomplete(
interaction):Promise<void>
Defined in: handlers/SlashCommandHandler.ts:100
Executes the autocomplete handler if it exists
Parameters
Section titled “Parameters”interaction
Section titled “interaction”AutocompleteInteraction<Context>
Returns
Section titled “Returns”Promise<void>
isGuildCommand()
Section titled “isGuildCommand()”isGuildCommand():
boolean
Defined in: handlers/SlashCommandHandler.ts:32
Whether this command is registered per-guild (true) or globally (false, the default).
Returns
Section titled “Returns”boolean
removeGuildIds()
Section titled “removeGuildIds()”removeGuildIds(…
guildIds):this
Defined in: handlers/SlashCommandHandler.ts:54
Removes one or more guild IDs from guildIds.
Parameters
Section titled “Parameters”guildIds
Section titled “guildIds”…string[]
Returns
Section titled “Returns”this
setGuildIds()
Section titled “setGuildIds()”setGuildIds(
guildIds):this
Defined in: handlers/SlashCommandHandler.ts:37
Replaces guildIds with the given list, making this a guild-scoped command.
Parameters
Section titled “Parameters”guildIds
Section titled “guildIds”string[]
Returns
Section titled “Returns”this
