Modal
Represents a modal for user interactions.
Example
1const modal = new Modal();2modal.setTitle("Sample Modal");3modal.addComponents(4 new ActionRow<TextInput>()5 .addComponents(new TextInput().setLabel("Enter text"))6));7modal.run((interaction) => {8 // Handle modal submission9});10const json = modal.toJSON();
Type parameters
Type parameter | Value | Description |
---|---|---|
T extends ModalBuilderComponents | TextInput | The type of components allowed in the modal. |
Constructors
new Modal(data)
1new Modal<T>(data: Partial<APIModalInteractionResponseCallbackData>): Modal<T>
Creates a new Modal instance.
Parameters
Parameter | Type | Description |
---|---|---|
data | Partial <APIModalInteractionResponseCallbackData > | Optional data for the modal. |
Returns
Modal
<T
>
Source
seyfert/src/builders/Modal.ts:38
Properties
Property | Modifier | Type | Description |
---|---|---|---|
components | public | ActionRow <T >[] | - |
data | public | Partial <APIModalInteractionResponseCallbackData > | Optional data for the modal. |
Methods
addComponents()
1addComponents(...components: RestOrArray<ActionRow<T>>): this
Adds components to the modal.
Parameters
Parameter | Type | Description |
---|---|---|
…components | RestOrArray <ActionRow <T >> | Components to be added to the modal. |
Returns
this
The current Modal instance.
Source
seyfert/src/builders/Modal.ts:47
run()
1run(func: ModalSubmitCallback): this
Sets the callback function to be executed when the modal is submitted.
Parameters
Parameter | Type | Description |
---|---|---|
func | ModalSubmitCallback | The callback function. |
Returns
this
The current Modal instance.
Source
seyfert/src/builders/Modal.ts:87
setComponents()
1setComponents(component: ActionRow<T>[]): this
Set the components to the modal.
Parameters
Parameter | Type | Description |
---|---|---|
component | ActionRow <T >[] | The components to set into the modal. |
Returns
this
The current Modal instance.
Source
seyfert/src/builders/Modal.ts:57
setCustomId()
1setCustomId(id: string): this
Sets the custom ID of the modal.
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The custom ID for the modal. |
Returns
this
The current Modal instance.
Source
seyfert/src/builders/Modal.ts:77
setTitle()
1setTitle(title: string): this
Sets the title of the modal.
Parameters
Parameter | Type | Description |
---|---|---|
title | string | The title of the modal. |
Returns
this
The current Modal instance.
Source
seyfert/src/builders/Modal.ts:67
toJSON()
1toJSON(): APIModalInteractionResponseCallbackData
Converts the modal to JSON format.
Returns
APIModalInteractionResponseCallbackData
The modal data in JSON format.