ModalBuilder

export declare class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData>
export declare class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData>
A builder that creates API-compatible JSON data for modals.
constructor(data?)
Creates a new modal from API data.
NameTypeOptionalDescription
dataPartial<APIModalInteractionResponseCallbackData>YesThe API data to create this modal with
Readonly
components:readonly ActionRowBuilder[]
The components within this modal.
addActionRows(...components):this
Adds action rows to this modal.
NameTypeOptionalDescription
...componentsRestOrArray<ActionRowBuilder | APIActionRowComponent<APIModalActionRowComponent> | ((builder: ActionRowBuilder) => ActionRowBuilder)>NoThe components to add
setActionRows(...components):this
Sets the action rows for this modal.
NameTypeOptionalDescription
...componentsRestOrArray<ActionRowBuilder | APIActionRowComponent<APIModalActionRowComponent> | ((builder: ActionRowBuilder) => ActionRowBuilder)>NoThe components to set
setCustomId(customId):this
Sets the custom id of this modal.
NameTypeOptionalDescription
customIdstringNoThe custom id to use
setTitle(title):this
Sets the title of this modal.
NameTypeOptionalDescription
titlestringNoThe title to use
spliceActionRows(index, deleteCount, ...rows):this
Removes, replaces, or inserts action rows for this modal.
Remarks
This method behaves similarly to Array.prototype.splice(). The maximum amount of action rows that can be added is 5.It's useful for modifying and adjusting order of the already-existing action rows of a modal.
Example
Remove the first action row:
embed.spliceActionRows(0, 1);
embed.spliceActionRows(0, 1);
Example
Remove the first n action rows:
const n = 4;
embed.spliceActionRows(0, n);
const n = 4;
embed.spliceActionRows(0, n);
Example
Remove the last action row:
embed.spliceActionRows(-1, 1);
embed.spliceActionRows(-1, 1);
NameTypeOptionalDescription
indexnumberNoThe index to start at
deleteCountnumberNoThe number of action rows to remove
...rows(ActionRowBuilder | APIActionRowComponent<APIModalActionRowComponent> | ((builder: ActionRowBuilder) => ActionRowBuilder))[]NoThe replacing action row objects
toJSON(validationOverride?):APIModalInteractionResponseCallbackData
Serializes this builder to API-compatible JSON data.Note that by disabling validation, there is no guarantee that the resulting object will be valid.
NameTypeOptionalDescription
validationOverridebooleanYesForce validation to run/not run regardless of your global preference