class ButtonBuilder

export declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent>

A builder that creates API-compatible JSON data for buttons.

Constructors

constructor()

Creates a new button from API data.

Examples:Creating a button from an API data object:
const button = new ButtonBuilder({
	custom_id: 'a cool button',
	style: ButtonStyle.Primary,
	label: 'Click Me',
	emoji: {
		name: 'smile',
		id: '123456789012345678',
	},
});
Creating a button using setters and API data:
const button = new ButtonBuilder({
	style: ButtonStyle.Secondary,
	label: 'Click Me',
})
	.setEmoji({ name: '🙂' })
	.setCustomId('another cool button');

readonly
data : Partial<APIButtonComponent>

The API data associated with this component.

Inherited from: ComponentBuilder

setCustomId(
customId: string
) : this

Sets the custom id for this button.

setDisabled(
disabled?: boolean
) : this

Sets whether this button is disabled.

setEmoji() : this

Sets the emoji to display on this button.

setLabel(
label: string
) : this

Sets the label for this button.

setStyle() : this

Sets the style of this button.

setURL(
url: string
) : this

Sets the URL for this button.

toJSON() : APIButtonComponent

Serializes this builder to API-compatible JSON data.