class ButtonBuilder
extends
ComponentBuilder<APIButtonComponent>export declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent>A builder that creates API-compatible JSON data for buttons.
Constructors
constructor(data?: Partial<APIButtonComponent>)
data?: Partial<APIButtonComponent>
Creates a new button from API data.
Examples:Creating a button from an API data object:Creating a button using setters and API data:
const button = new ButtonBuilder({
custom_id: 'a cool button',
style: ButtonStyle.Primary,
label: 'Click Me',
emoji: {
name: 'smile',
id: '123456789012345678',
},
});const button = new ButtonBuilder({
style: ButtonStyle.Secondary,
label: 'Click Me',
})
.setEmoji({ name: '🙂' })
.setCustomId('another cool button');readonlydata : Partial<APIButtonComponent>
The API data associated with this component.
Inherited from: ComponentBuilder
Clears the id of this component, defaulting to a default incremented id.
Inherited from: ComponentBuilder
setCustomId(customId: string) : this
customId: string
Sets the custom id for this button.
setDisabled(disabled?: boolean) : this
disabled?: boolean
Sets whether this button is disabled.
setEmoji(emoji: APIMessageComponentEmoji) : this
emoji: APIMessageComponentEmoji
Sets the emoji to display on this button.
setId(id: number) : this
id: number
Sets the id (not the custom id) for this component.
Inherited from: ComponentBuilder
setLabel(label: string) : this
label: string
Sets the label for this button.
setSKUId(skuId: Snowflake) : this
skuId: Snowflake
Sets the SKU id that represents a purchasable SKU for this button.
setStyle(style: ButtonStyle) : this
style: ButtonStyle
Sets the style of this button.
setURL(url: string) : this
url: string
Sets the URL for this button.
toJSON() : APIButtonComponent
Serializes this builder to API-compatible JSON data.