ContextMenuHandler
Base class for a context-menu command handler (right-click a user or a message).
Pass the kind from discord.js's ApplicationCommandType as the generic, the same value as @ContextMenuRoute. Read the right-clicked entity from this.target, a User for a user menu and a Message for a message menu. Context menus carry no options, so a handler registered for several names reads this.target uniformly with no per-name branch.
abstract class ContextMenuHandler<
Kind extends ContextMenuKind,
Cache extends CacheType = "cached"
> extends InteractionHandler<InteractionFor<Kind, Cache>>Member visibility
Filter class members by access level.
constructor
Constructs a new instance of the InteractionHandler class
InteractionHandler(
event: Repliable,
core: Core,
dispatch?: DispatchContext
)Inherited from:InteractionHandler
Showing members with Protected visibility and higher.
Kind
ApplicationCommandType.User or ApplicationCommandType.Message.
Kind extends ContextMenuKindCache
The interaction cache state, 'cached' by default.
Cache extends CacheType = 'cached'core
readonly core: TCoreInherited from:BaseHandler
- optional
dispatch
protected readonly dispatch: DispatchContext | undefinedInherited from:BaseHandler
event
protected readonly event: EventInherited from:BaseHandler
logger
protected readonly logger: LoggerInherited from:BaseHandler
routeId
protected readonly routeId: stringInherited from:RepliableHandler
sender
protected readonly sender: TSenderInherited from:RepliableHandler
protected target: TargetFor<Kind, Cache>protected targetMember: TargetMemberFor<Kind, Cache>buildSender()
protected buildSender(
event: Event,
core: Core,
routeId: string
): ReplySenderInherited from:RepliableHandler
defer()
Show a "thinking" placeholder, then fill it later with edit.
Inherited from:RepliableHandler
delete()
Delete the initial reply or deferred placeholder. Pass a target to delete a message a prior send returned.
Inherited from:RepliableHandler
edit()
Rewrite the initial reply or deferred placeholder. The targeted form rewrites a message a prior send returned.
protected async edit(
response: ReplyResponse<TNative> | string
): Promise<TMessage>Inherited from:RepliableHandler
execute()
Holds the main logic of your handler. The dispatcher calls it after the handler's gates pass, so a gate that refuses stops execute() from running.
Inherited from:BaseHandler
followUp()
Send a new message once the interaction is acknowledged.
protected async followUp(
response: ReplyResponse<TNative> | string,
opts?: SendOpts
): Promise<TMessage>Inherited from:RepliableHandler
reply()
Send the initial response, exactly once.
protected async reply(
response: ReplyResponse<TNative> | string,
opts?: SendOpts
): Promise<TMessage>Inherited from:RepliableHandler
send()
Routes to reply, followUp, or edit based on the current ack state.
protected async send(
response: ReplyResponse<TNative> | string,
opts?: SendOpts
): Promise<TMessage>Inherited from:RepliableHandler
showModal()
Open a modal. Must be the initial response to this interaction. The modal kind rejects this call at compile time (Discord forbids a modal in response to a modal).
protected async showModal(
this: InteractionHandler<NonModalInteraction>,
modal: ModalLike
): Promise<void>Inherited from:InteractionHandler