ContextCommandHandler
Class: ContextCommandHandler<Context, T, InteractionData>
Section titled “Class: ContextCommandHandler<Context, T, InteractionData>”Defined in: handlers/ContextCommandHandler.ts:13
Handler for user and message context menu commands.
Extends
Section titled “Extends”ContextMenuCommandBuilder
Type Parameters
Section titled “Type Parameters”Context
Section titled “Context”Context extends BaseInteractionContext = BaseInteractionContext
Interaction context type
T extends ContextCommandType = ContextCommandType
Which context command type this handler serves (User or Message)
InteractionData
Section titled “InteractionData”InteractionData = T extends User ? UserContextInteraction<Context> : MessageContextInteraction<Context>
The interaction type passed to the handler function, inferred from T
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ContextCommandHandler<
Context,T,InteractionData>(commandType):ContextCommandHandler<Context,T,InteractionData>
Defined in: handlers/ContextCommandHandler.ts:18
Parameters
Section titled “Parameters”commandType
Section titled “commandType”T
Returns
Section titled “Returns”ContextCommandHandler<Context, T, InteractionData>
Overrides
Section titled “Overrides”ContextMenuCommandBuilder.constructor
Properties
Section titled “Properties”commandType
Section titled “commandType”
readonlycommandType:T
Defined in: handlers/ContextCommandHandler.ts:18
guildIds
Section titled “guildIds”
readonlyguildIds:Set<string>
Defined in: handlers/ContextCommandHandler.ts:28
Set of guild IDs where this command is registered (empty for global commands)
handlerType
Section titled “handlerType”
readonlyhandlerType:"context"="context"
Defined in: handlers/ContextCommandHandler.ts:23
Methods
Section titled “Methods”addGuildIds()
Section titled “addGuildIds()”addGuildIds(…
guildIds):this
Defined in: handlers/ContextCommandHandler.ts:45
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):ContextCommandHandler<Context,T,InteractionData>
Defined in: handlers/ContextCommandHandler.ts:66
Adds the command handler function.
Parameters
Section titled “Parameters”handler
Section titled “handler”(interaction) => any
The function to handle the context command interaction
Returns
Section titled “Returns”ContextCommandHandler<Context, T, InteractionData>
The current ContextCommandHandler instance
execute()
Section titled “execute()”execute(
interaction):Promise<void>
Defined in: handlers/ContextCommandHandler.ts:76
Executes the command handler
Parameters
Section titled “Parameters”interaction
Section titled “interaction”InteractionData
Returns
Section titled “Returns”Promise<void>
isGuildCommand()
Section titled “isGuildCommand()”isGuildCommand():
boolean
Defined in: handlers/ContextCommandHandler.ts:31
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/ContextCommandHandler.ts:53
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/ContextCommandHandler.ts:36
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
