ComponentHandler
Shared base the customId-routed component handlers extend.
Not a public entry point. Extend ButtonHandlerButtonHandler, SelectMenuHandlerSelectMenuHandler, or ModalHandlerModalHandler instead. This class defines the customId decode and the route matching those bases share.
abstract class ComponentHandler<
Event extends ComponentInteraction,
Defs extends readonly AnyCustomId[]
>
extends InteractionHandler<Event>
implements HasComponentDefs<Defs>abstract class ComponentHandler<
Event extends ComponentInteraction,
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 InteractionHandlerInteractionHandler class
InteractionHandler(
event: Repliable,
core: Core,
dispatch?: DispatchContext
)InteractionHandler(
event: Repliable,
core: Core,
dispatch?: DispatchContext
)Inherited from:InteractionHandler
Showing members with Protected visibility and higher.
Properties
Methods
Event
The component interaction type this handler processes
Event extends ComponentInteractionEvent extends ComponentInteractionDefs
The customId route definitions registered on the concrete handler
Defs extends readonly AnyCustomId[]Defs extends readonly AnyCustomId[]The decoded params of the single route this handler is registered for.
Reading this decodes this.event.customIdthis.event.customId once (cached after the first read) and throws StaleCustomIdStaleCustomId or InvalidCustomIdInvalidCustomId when the wire no longer matches the current shape, which the controller boundary turns into a reply. On a handler registered for several routes this is nevernever, so use matchmatch instead.
protected params: SingleParams<Defs>protected params: SingleParams<Defs>buildSender()
protected buildSender(
event: Event,
_core: Core,
routeId: string
): ReplySenderprotected 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.paramsthis.params directly. On a multi-route handler this.paramsthis.params is nevernever, 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 CustomIdMatchArmMissingCustomIdMatchArmMissing. Decoding runs before any arm, so a stale or corrupt wire throws before an arm body executes.
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>protected async showModal(
this: InteractionHandler<NonModalInteraction>,
modal: ModalLike
): Promise<void>Inherited from:InteractionHandler
protected async update(
response: ReplyResponse | string
): Promise<SentMessage>protected async update(
response: ReplyResponse | string
): Promise<SentMessage>