Search...

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.

Implements

JSONEncodable<APIModalInteractionResponseCallbackData>

constructor({ components, ...data }?)

Creates a new modal from API data.
NameTypeOptionalDescription
{ components, ...data }Partial<APIModalInteractionResponseCallbackData>YesNone
The components within this modal.
Readonly

data

:

Partial<APIModalInteractionResponseCallbackData>

The API data associated with this modal.

addComponents(components)

:

this

Adds components to this modal.
NameTypeOptionalDescription
componentsRestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>>NoThe components to add

setComponents(components)

:

this

Sets components for this modal.
NameTypeOptionalDescription
componentsRestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>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

toJSON()

:

APIModalInteractionResponseCallbackData

Serializes this builder to API-compatible JSON data.
Remarks
This method runs validations on the data before serializing it. As such, it may throw an error if the data is invalid.