ButtonBuilder
The Button class is a class that represents a button.
Kind: global class
new ButtonBuilder()
Section titled “new ButtonBuilder()”The function takes an object as an argument, and then assigns the object’s properties to the function’s properties.
buttonBuilder.setLabel(label)
Section titled “buttonBuilder.setLabel(label)”This function sets the label property of the component to the value of the label parameter.
Kind: instance method of ButtonBuilder
Access: public
| Param | Type | Description |
|---|---|---|
| label | string | The label of the button. |
buttonBuilder.setEmoji(emoji)
Section titled “buttonBuilder.setEmoji(emoji)”This function sets the emoji property of the component to the emoji passed in as an argument.
Kind: instance method of ButtonBuilder
Access: public
| Param | Type | Description |
|---|---|---|
| emoji | Object | The emoji to set. |
buttonBuilder.setDisabled() ⇒
Section titled “buttonBuilder.setDisabled() ⇒”setDisabled() sets the disabled property to true and returns the object.
Kind: instance method of ButtonBuilder
Returns: The object itself.
buttonBuilder.setStyle(style) ⇒
Section titled “buttonBuilder.setStyle(style) ⇒”setStyle is a function that takes a parameter called style and sets the value of the style
property of the object that called it to the value of the style parameter.
The return this statement at the end of the function is a common pattern in JavaScript. It allows
us to chain function calls together. For example, we can call setStyle and then immediately call
setColor like this:
Kind: instance method of ButtonBuilder
Returns: The object itself.
Access: public
| Param | Type | Description |
|---|---|---|
| style | number | The style to apply to the element. |
buttonBuilder.setUrl(url)
Section titled “buttonBuilder.setUrl(url)”This function sets the url property of the component to the url passed in as an argument.
Kind: instance method of ButtonBuilder
Access: public
| Param | Type | Description |
|---|---|---|
| url | string | The URL of the page to be loaded. |
buttonBuilder.setCustomId(customid)
Section titled “buttonBuilder.setCustomId(customid)”This function sets the customid property of the component to the value of the customid parameter.
Kind: instance method of ButtonBuilder
Access: public
| Param | Type | Description |
|---|---|---|
| customid | string | The custom id of the user. |
buttonBuilder.toJSON() ⇒
Section titled “buttonBuilder.toJSON() ⇒”It returns an object with the properties of the button.
Kind: instance method of ButtonBuilder
Returns: An object with the properties type, custom_id, style, label, emoji, disabled, and url.
Access: public
ButtonBuilder.transformFields(fields) ⇒
Section titled “ButtonBuilder.transformFields(fields) ⇒”This function takes an object with properties named ‘emoji’, ‘text’, ‘url’, ‘customid’, ‘style’, and ‘disabled’, and returns an object with the same properties, but with the names changed to ‘emoji’, ‘label’, ‘url’, ‘customid’, ‘style’, and ‘disabled’.
Kind: static method of ButtonBuilder
Returns: The transformFields function is returning an object with the following properties:
emoji, label, url, customid, style, and disabled.
Access: public
| Param | Description |
|---|---|
| fields | The fields object that is passed to the component. |