Skip to main content
Version: Next

ModalKit

ModalKit extends ModalBuilder

new ModalKit(data)
ParameterTypeOptional
dataPartial<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.

ParameterTypeOptionalDescription
componentsRestOrArray<ActionRowBuilder<TextInputBuilder>APIActionRowComponent<APITextInputComponent>>The components to add

public dispose(): ModalKit

public filter(predicate): this

Sets a filter for the interaction collector.

ParameterTypeOptionalDescription
predicateModalKitPredicateThe filter to use for the interaction collector.

public onEnd(handler): this

Sets the handler to run when the interaction collector ends.

ParameterTypeOptionalDescription
handlerCommandKitModalBuilderOnEndThe handler to run when the interaction collector ends.

public onError(handler): this

Sets the handler to run when the interaction collector ends.

ParameterTypeOptionalDescription
handlerEventInterceptorErrorHandlerThe 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);
ParameterTypeOptionalDescription
handlerCommandKitModalBuilderInteractionCollectorDispatchThe handler to run when the modal is submitted.
dataCommandKitModalBuilderInteractionCollectorDispatchContextDataThe context data for the interaction collector.

public setComponents(components): this

Sets components for this modal.

ParameterTypeOptionalDescription
componentsRestOrArray<ActionRowBuilder<TextInputBuilder>>The components to set

public setCustomId(customId): this

Sets the custom id of this modal.

ParameterTypeOptionalDescription
customIdstringThe custom id to use

public setTitle(title): this

Sets the title of this modal.

ParameterTypeOptionalDescription
titlestringThe title to use

public toJSON(): APIModalInteractionResponseCallbackData

ComponentBuilder.toJSON

public static from(other): ModalBuilder

ParameterTypeOptional
otherAPIModalInteractionResponseCallbackDataJSONEncodable<APIModalInteractionResponseCallbackData>