ComponentHandler
Shared base the customId-routed component handlers extend on the HTTP transport.
Not a public entry point. Extend ButtonHandler, SelectMenuHandler, or ModalHandler instead. This class defines the customId decode, the route matching, and the source-message verbs update and deferUpdate.
abstract class ComponentHandler<
Event extends APIMessageComponentInteraction | APIModalSubmitInteraction,
Defs extends readonly AnyCustomId[]
>
extends InteractionHandler<Event>
implements HasComponentDefs<Defs>Member visibility
Filter class members by access level.
constructor
Constructs a new instance of the InteractionHandler class
InteractionHandler(
event: Event,
core: Core,
dispatch?: DispatchContext
)Inherited from:InteractionHandler
Showing members with Protected visibility and higher.
Properties
Methods
Event
The component or modal interaction type this handler processes
Event extends APIMessageComponentInteraction | APIModalSubmitInteractionDefs
The customId route definitions registered on the concrete handler
Defs extends readonly AnyCustomId[]api
Typed Discord REST API (@discordjs/core/http-only) over core.rest, one instance per core. The interaction callbacks on api.interactions bypass the reply surface. The no-raw-interaction-acks rule flags them in handler classes.
protected api: APIInherited from:RepliableHandler
The decoded params of the single route this handler is registered for.
Reading this decodes this.event.data.custom_id once (cached after the first read) and throws StaleCustomId or InvalidCustomId when the wire no longer matches the current shape, which the dispatcher boundary turns into a reply. On a handler registered for several routes this is never, so use match instead.
protected params: SingleParams<Defs>buildSender()
protected buildSender(
event: Event,
core: Core,
routeId: string
): ReplySenderInherited from:RepliableHandler
Run the arm for whichever route the component was minted from. Use this only when the handler is registered for several routes. A single-route handler reads this.params directly. On a multi-route handler this.params is never, so match is the only way to read the decoded params.
Provide one arm per registered route, keyed by its prefix, and each arm receives that route's own decoded params. The arms cover every registered route prefix, checked at compile time, and a prefix unmatched at runtime throws CustomIdMatchArmMissing. Decoding runs before any arm, so a stale or corrupt wire throws before an arm body executes.
protected async match<Ret>(arms: MatchArms<Defs, Ret>): Promise<Ret>armsOne callback per registered route, keyed by prefix.
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<
Exclude<Repliables, APIModalSubmitInteraction>
>,
modal: ModalLike
): Promise<void>Inherited from:InteractionHandler
protected async update(
response: ReplyResponse | string
): Promise<SentMessage>