ComponentHandler
Class: ComponentHandler<Context, CType>
Section titled “Class: ComponentHandler<Context, CType>”Defined in: handlers/ComponentHandler.ts:7
Handler for message components (buttons, select menus) based on custom ID prefix
Type Parameters
Section titled “Type Parameters”Context
Section titled “Context”Context extends BaseInteractionContext = BaseInteractionContext
CType extends MessageComponentType = MessageComponentType
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ComponentHandler<
Context,CType>(prefix,componentType,handler?):ComponentHandler<Context,CType>
Defined in: handlers/ComponentHandler.ts:21
Parameters
Section titled “Parameters”prefix
Section titled “prefix”string
The custom ID prefix this handler matches against. See the Custom ID System guide.
componentType
Section titled “componentType”CType
The message component type this handler is registered for
handler?
Section titled “handler?”(interaction) => any
Optional handler function, equivalent to calling addHandler afterwards
Returns
Section titled “Returns”ComponentHandler<Context, CType>
Properties
Section titled “Properties”componentType
Section titled “componentType”
readonlycomponentType:CType
Defined in: handlers/ComponentHandler.ts:13
handlerType
Section titled “handlerType”
readonlyhandlerType:"component"="component"
Defined in: handlers/ComponentHandler.ts:11
prefix
Section titled “prefix”
readonlyprefix:string
Defined in: handlers/ComponentHandler.ts:12
Methods
Section titled “Methods”addHandler()
Section titled “addHandler()”addHandler(
handler):ComponentHandler<Context,CType>
Defined in: handlers/ComponentHandler.ts:41
Adds the component handler function.
Parameters
Section titled “Parameters”handler
Section titled “handler”(interaction) => any
The function to handle the component interaction
Returns
Section titled “Returns”ComponentHandler<Context, CType>
The current ComponentHandler instance
execute()
Section titled “execute()”execute(
interaction):Promise<void>
Defined in: handlers/ComponentHandler.ts:51
Executes the component handler
Parameters
Section titled “Parameters”interaction
Section titled “interaction”MessageComponentInteractionObj<Context, CType>
Returns
Section titled “Returns”Promise<void>
matches()
Section titled “matches()”matches(
customId):boolean
Defined in: handlers/ComponentHandler.ts:61
Checks if this handler matches the given custom ID
Parameters
Section titled “Parameters”customId
Section titled “customId”string
Returns
Section titled “Returns”boolean
