ActionRowBuilder

export declare class ActionRowBuilder<ComponentType extends AnyComponentBuilder> extends ComponentBuilder<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>>
export declare class ActionRowBuilder<ComponentType extends AnyComponentBuilder> extends ComponentBuilder<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>>
A builder that creates API-compatible JSON data for action rows.
NameConstraintsOptionalDefaultDescription
ComponentTypeAnyComponentBuilderNoThe types of components this action row holds
constructor(data?)
Creates a new action row from API data.
Example
Creating an action row from an API data object:
const actionRow = new ActionRowBuilder({
components: [
{
custom_id: "custom id",
label: "Type something",
style: TextInputStyle.Short,
type: ComponentType.TextInput,
},
],
});
const actionRow = new ActionRowBuilder({
components: [
{
custom_id: "custom id",
label: "Type something",
style: TextInputStyle.Short,
type: ComponentType.TextInput,
},
],
});
Example
Creating an action row using setters and API data:
const actionRow = new ActionRowBuilder({
components: [
{
custom_id: "custom id",
label: "Click me",
style: ButtonStyle.Primary,
type: ComponentType.Button,
},
],
})
.addComponents(button2, button3);
const actionRow = new ActionRowBuilder({
components: [
{
custom_id: "custom id",
label: "Click me",
style: ButtonStyle.Primary,
type: ComponentType.Button,
},
],
})
.addComponents(button2, button3);
NameTypeOptionalDescription
dataPartial<APIActionRowComponent<APIActionRowComponentTypes>>YesThe API data to create this action row with
Readonly
components:ComponentType[]
The components within this action row.
The API data associated with this component.
Inherited from ComponentBuilder
addComponents(...components):this
Adds components to this action row.
NameTypeOptionalDescription
...componentsRestOrArray<ComponentType>NoThe components to add
setComponents(...components):this
Sets components for this action row.
NameTypeOptionalDescription
...componentsRestOrArray<ComponentType>NoThe components to set
toJSON():APIActionRowComponent<ReturnType<ComponentType['toJSON']>>
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.