Skip to content
V2 has arrived! A lot has changed, so treat this as a fresh start.

ModalHandler

ModalHandler is used to handle modal submissions based on a custom ID prefix.

new ModalHandler(
prefix: string,
handler?: (interaction: ModalInteraction<Context>) => Promise<any> | any
)
  • prefix: string — The unique prefix of the custom_id to match this handler.
  • handler? — An optional initial handler function for the modal submission.

The type identifier for this handler.

The custom ID prefix this handler listens for.

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.

Checks if a given customId matches this handler’s prefix.