A builder that creates API-compatible JSON data for buttons.
Extends
ComponentBuilder<APIButtonComponent>constructor(data?)
Creates a new button from API data.
Example
Creating a button from an API data object:Example
Creating a button using setters and API data:Name | Type | Optional | Description |
---|---|---|---|
data | Partial<APIButtonComponent> | Yes | The API data to create this button with |
Readonly
data
:
Partial<DataType>
The API data associated with this component.
Inherited from ComponentBuildersetCustomId(customId)
:
this
Sets the custom id for this button.
Remarks
This method is only applicable to buttons that are not using theLink
button style.Name | Type | Optional | Description |
---|---|---|---|
customId | string | No | The custom id to use |
setDisabled(disabled?)
:
this
Sets whether this button is disabled.
Name | Type | Optional | Description |
---|---|---|---|
disabled | boolean | Yes | Whether to disable this button |
setEmoji(emoji)
:
this
Sets the emoji to display on this button.
Name | Type | Optional | Description |
---|---|---|---|
emoji | APIMessageComponentEmoji | No | The emoji to use |
setLabel(label)
:
this
Sets the label for this button.
Name | Type | Optional | Description |
---|---|---|---|
label | string | No | The label to use |
setStyle(style)
:
this
Sets the style of this button.
Name | Type | Optional | Description |
---|---|---|---|
style | ButtonStyle | No | The style to use |
setURL(url)
:
this
Sets the URL for this button.
Remarks
This method is only available to buttons using theLink
button style. Only three types of URL schemes are currently supported: https://
, http://
, and discord://
.Name | Type | Optional | Description |
---|---|---|---|
url | string | No | The URL to use |
toJSON()
:
APIButtonComponent
Serializes this builder to API-compatible JSON data.