ModalHandler
ModalHandler is used to handle modal submissions based on a custom ID prefix.
Constructor
Section titled “Constructor”new ModalHandler( prefix: string, handler?: (interaction: ModalInteraction<Context>) => Promise<any> | any)prefix: string— The unique prefix of thecustom_idto match this handler.handler?— An optional initial handler function for the modal submission.
Public Properties
Section titled “Public Properties”handlerType: "modal" (readonly)
Section titled “handlerType: "modal" (readonly)”The type identifier for this handler.
prefix: string (readonly)
Section titled “prefix: string (readonly)”The custom ID prefix this handler listens for.
Public Methods
Section titled “Public Methods”addHandler(handler: (interaction: ModalInteraction<Context>) => Promise<any> | any): this
Section titled “addHandler(handler: (interaction: ModalInteraction<Context>) => Promise<any> | any): this”Sets the function to handle the modal interaction.
execute(interaction: ModalInteraction<Context>): Promise<void>
Section titled “execute(interaction: ModalInteraction<Context>): Promise<void>”Executes the registered handler.
matches(customId: string): boolean
Section titled “matches(customId: string): boolean”Checks if a given customId matches this handler’s prefix.