ContextCommandHandler
ContextCommandHandler is used to define and manage Discord context menu commands (User or Message). It extends @discordjs/builders’s ContextMenuCommandBuilder.
Constructor
Section titled “Constructor”new ContextCommandHandler(commandType: ContextCommandType)commandType: ContextCommandType— EitherContextCommandType.UserorContextCommandType.Message.
Public Properties
Section titled “Public Properties”commandType: ContextCommandType (readonly)
Section titled “commandType: ContextCommandType (readonly)”The type of context command (User or Message).
guildIds: Set<string> (readonly)
Section titled “guildIds: Set<string> (readonly)”A set of guild IDs where this command is registered. If empty, it’s a global command.
handlerType: "context" (readonly)
Section titled “handlerType: "context" (readonly)”The type identifier for this handler.
Public Methods
Section titled “Public Methods”addGuildIds(...guildIds: string[]): this
Section titled “addGuildIds(...guildIds: string[]): this”Adds guild IDs to the existing set.
addHandler(handler: (interaction: InteractionData) => Promise<any> | any): this
Section titled “addHandler(handler: (interaction: InteractionData) => Promise<any> | any): this”Sets the function to handle the context menu interaction.
execute(interaction: InteractionData): Promise<void>
Section titled “execute(interaction: InteractionData): Promise<void>”Executes the registered handler.
isGuildCommand(): boolean
Section titled “isGuildCommand(): boolean”Returns whether the command is restricted to specific guilds.
removeGuildIds(...guildIds: string[]): this
Section titled “removeGuildIds(...guildIds: string[]): this”Removes specific guild IDs.
setGuildIds(guildIds: string[]): this
Section titled “setGuildIds(guildIds: string[]): this”Clears and sets the guild IDs.