Skip to content

Modal

Represents a modal for user interactions.

Example

1
const modal = new Modal();
2
modal.setTitle("Sample Modal");
3
modal.addComponents(
4
new ActionRow<TextInput>()
5
.addComponents(new TextInput().setLabel("Enter text"))
6
));
7
modal.run((interaction) => {
8
// Handle modal submission
9
});
10
const json = modal.toJSON();

Type parameters

Type parameterValueDescription
T extends ModalBuilderComponentsTextInputThe type of components allowed in the modal.

Constructors

new Modal(data)

1
new Modal<T>(data: Partial<APIModalInteractionResponseCallbackData>): Modal<T>

Creates a new Modal instance.

Parameters

ParameterTypeDescription
dataPartial<APIModalInteractionResponseCallbackData>Optional data for the modal.

Returns

Modal<T>

Source

seyfert/src/builders/Modal.ts:38

Properties

PropertyModifierTypeDescription
componentspublicActionRow<T>[]-
datapublicPartial<APIModalInteractionResponseCallbackData>Optional data for the modal.

Methods

addComponents()

1
addComponents(...components: RestOrArray<ActionRow<T>>): this

Adds components to the modal.

Parameters

ParameterTypeDescription
componentsRestOrArray<ActionRow<T>>Components to be added to the modal.

Returns

this

The current Modal instance.

Source

seyfert/src/builders/Modal.ts:47


run()

1
run(func: ModalSubmitCallback): this

Sets the callback function to be executed when the modal is submitted.

Parameters

ParameterTypeDescription
funcModalSubmitCallbackThe callback function.

Returns

this

The current Modal instance.

Source

seyfert/src/builders/Modal.ts:87


setComponents()

1
setComponents(component: ActionRow<T>[]): this

Set the components to the modal.

Parameters

ParameterTypeDescription
componentActionRow<T>[]The components to set into the modal.

Returns

this

The current Modal instance.

Source

seyfert/src/builders/Modal.ts:57


setCustomId()

1
setCustomId(id: string): this

Sets the custom ID of the modal.

Parameters

ParameterTypeDescription
idstringThe custom ID for the modal.

Returns

this

The current Modal instance.

Source

seyfert/src/builders/Modal.ts:77


setTitle()

1
setTitle(title: string): this

Sets the title of the modal.

Parameters

ParameterTypeDescription
titlestringThe title of the modal.

Returns

this

The current Modal instance.

Source

seyfert/src/builders/Modal.ts:67


toJSON()

1
toJSON(): APIModalInteractionResponseCallbackData

Converts the modal to JSON format.

Returns

APIModalInteractionResponseCallbackData

The modal data in JSON format.

Source

seyfert/src/builders/Modal.ts:96