ModalKit
ModalKit extends ModalBuilder
new ModalKit(data)
| Parameter | Type | Optional | 
|---|---|---|
| data | Partial<APIModalInteractionResponseCallbackData> | Partial<ModalComponentData> | ✅ | 
Properties
public components: any
The components within this modal.
public data: any
The API data associated with this modal.
Methods
public addComponents(components): this
Adds components to this modal.
| Parameter | Type | Optional | Description | 
|---|---|---|---|
| components | RestOrArray<ActionRowBuilder<TextInputBuilder>APIActionRowComponent<APITextInputComponent>> | ❌ | The components to add | 
public dispose(): ModalKit
public filter(predicate): this
Sets a filter for the interaction collector.
| Parameter | Type | Optional | Description | 
|---|---|---|---|
| predicate | ModalKitPredicate | ❌ | The filter to use for the interaction collector. | 
public onEnd(handler): this
Sets the handler to run when the interaction collector ends.
| Parameter | Type | Optional | Description | 
|---|---|---|---|
| handler | CommandKitModalBuilderOnEnd | ❌ | The handler to run when the interaction collector ends. | 
public onError(handler): this
Sets the handler to run when the interaction collector ends.
| Parameter | Type | Optional | Description | 
|---|---|---|---|
| handler | EventInterceptorErrorHandler | ❌ | The handler to run when the interaction collector ends. | 
public onSubmit(handler, data?): this
Sets the handler to run when the modal is submitted.
const modal = new ModalKit()
 .setTitle('My Modal')
 .setCustomId('my-modal')
 .filter((interaction) => interaction.user.id === '1234567890')
 .onSubmit(async (interaction) => {
    await interaction.reply('You submitted the modal!');
  })
  .addComponents(actionRow1, actionRow2);
| Parameter | Type | Optional | Description | 
|---|---|---|---|
| handler | CommandKitModalBuilderInteractionCollectorDispatch | ❌ | The handler to run when the modal is submitted. | 
| data | CommandKitModalBuilderInteractionCollectorDispatchContextData | ✅ | The context data for the interaction collector. | 
public setComponents(components): this
Sets components for this modal.
| Parameter | Type | Optional | Description | 
|---|---|---|---|
| components | RestOrArray<ActionRowBuilder<TextInputBuilder>> | ❌ | The components to set | 
public setCustomId(customId): this
Sets the custom id of this modal.
| Parameter | Type | Optional | Description | 
|---|---|---|---|
| customId | string | ❌ | The custom id to use | 
public setTitle(title): this
Sets the title of this modal.
| Parameter | Type | Optional | Description | 
|---|---|---|---|
| title | string | ❌ | The title to use | 
public toJSON(): APIModalInteractionResponseCallbackData
ComponentBuilder.toJSON
public static from(other): ModalBuilder
| Parameter | Type | Optional | 
|---|---|---|
| other | APIModalInteractionResponseCallbackData | JSONEncodable<APIModalInteractionResponseCallbackData> |