ModalHandler
Class: ModalHandler<Context>
Section titled “Class: ModalHandler<Context>”Defined in: handlers/ModalHandler.ts:8
Handler for modal submits based on custom ID prefix
Type Parameters
Section titled “Type Parameters”Context
Section titled “Context”Context extends BaseInteractionContext = BaseInteractionContext
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ModalHandler<
Context>(prefix,handler?):ModalHandler<Context>
Defined in: handlers/ModalHandler.ts:17
Parameters
Section titled “Parameters”prefix
Section titled “prefix”string
The custom ID prefix this handler matches against. See the Custom ID System guide.
handler?
Section titled “handler?”(interaction) => any
Optional handler function, equivalent to calling addHandler afterwards
Returns
Section titled “Returns”ModalHandler<Context>
Properties
Section titled “Properties”handlerType
Section titled “handlerType”
readonlyhandlerType:"modal"="modal"
Defined in: handlers/ModalHandler.ts:9
prefix
Section titled “prefix”
readonlyprefix:string
Defined in: handlers/ModalHandler.ts:10
Methods
Section titled “Methods”addHandler()
Section titled “addHandler()”addHandler(
handler):ModalHandler<Context>
Defined in: handlers/ModalHandler.ts:32
Adds the modal handler function.
Parameters
Section titled “Parameters”handler
Section titled “handler”(interaction) => any
The function to handle the modal submit interaction
Returns
Section titled “Returns”ModalHandler<Context>
The current ModalHandler instance
execute()
Section titled “execute()”execute(
interaction):Promise<void>
Defined in: handlers/ModalHandler.ts:40
Executes the modal handler
Parameters
Section titled “Parameters”interaction
Section titled “interaction”ModalInteraction<Context>
Returns
Section titled “Returns”Promise<void>
matches()
Section titled “matches()”matches(
customId):boolean
Defined in: handlers/ModalHandler.ts:50
Checks if this handler matches the given custom ID
Parameters
Section titled “Parameters”customId
Section titled “customId”string
Returns
Section titled “Returns”boolean
