Skip to content

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.

  • ContextMenuCommandBuilder

Context extends BaseInteractionContext = BaseInteractionContext

Interaction context type

T extends ContextCommandType = ContextCommandType

Which context command type this handler serves (User or Message)

InteractionData = T extends User ? UserContextInteraction<Context> : MessageContextInteraction<Context>

The interaction type passed to the handler function, inferred from T

new ContextCommandHandler<Context, T, InteractionData>(commandType): ContextCommandHandler<Context, T, InteractionData>

Defined in: handlers/ContextCommandHandler.ts:18

T

ContextCommandHandler<Context, T, InteractionData>

ContextMenuCommandBuilder.constructor

readonly commandType: T

Defined in: handlers/ContextCommandHandler.ts:18


readonly guildIds: Set<string>

Defined in: handlers/ContextCommandHandler.ts:28

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


readonly handlerType: "context" = "context"

Defined in: handlers/ContextCommandHandler.ts:23

addGuildIds(…guildIds): this

Defined in: handlers/ContextCommandHandler.ts:45

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

…string[]

this


addHandler(handler): ContextCommandHandler<Context, T, InteractionData>

Defined in: handlers/ContextCommandHandler.ts:66

Adds the command handler function.

(interaction) => any

The function to handle the context command interaction

ContextCommandHandler<Context, T, InteractionData>

The current ContextCommandHandler instance


execute(interaction): Promise<void>

Defined in: handlers/ContextCommandHandler.ts:76

Executes the command handler

InteractionData

Promise<void>


isGuildCommand(): boolean

Defined in: handlers/ContextCommandHandler.ts:31

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

boolean


removeGuildIds(…guildIds): this

Defined in: handlers/ContextCommandHandler.ts:53

Removes one or more guild IDs from guildIds.

…string[]

this


setGuildIds(guildIds): this

Defined in: handlers/ContextCommandHandler.ts:36

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

string[]

this