ButtonBuilder class
constructor
The constructor provides one optional argument which is an object which provides the data for the ButtonBuilder class.
The object may contain the following information:
custom_id
: An id so you can recognize the button when it's being pressed by a member. The id must be unique and a string between 1-100 characters.style
: A number which defines which kind of style the button should have.label
: The text which should be on the button. The string must be between 1-100 characters.emoji
: An object which defines the emoji which should be on the button, if you want an emoji on the button. The object should provide whether the emoji is animated or not, the id of the emoji and the name of the emoji.disabled
: A boolean which defines whether the button can be pressed or not.url
: A url for the member to go to when the member presses the button.type
: A number which defines the type of component of the button. (2
means it's a button)
Properties
data
An object which makes it a valid object for the Discord API.
Functions
setCustomId
Sets a custom id for the button which will be returned to the bot once the button is pressed and makes you able to recognize the button. The function returns the same ButtonBuilder class so you don't have to declare it everytime again.
setDisabled
Defines whether the button may be pressed by a member or not. The function returns the same ButtonBuilder class so you don't have to declare it everytime again.
setLabel
Sets a label for the button which is visible to server members. The function returns the same ButtonBuilder class so you don't have to declare it everytime again.
setText
Identical to the setLabel function. Sets a label for the button which is visible to server members. The function returns the same ButtonBuilder class so you don't have to declare it everytime again.
setStyle
Sets the style for the button and defines how the button will look like. The function returns the same ButtonBuilder class so you don't have to declare it everytime again.
setURL
Sets a url for the button so when a member presses the button, the member will be redirected to the website. When setting the url, the style type will automatically change to a url button style. The function returns the same ButtonBuilder class so you don't have to declare it everytime again.
setEmoji
Adds an emoji to the button. The emoji must be a unicode emoji or an instance of the Emoji class. The function returns the same ButtonBuilder class so you don't have to declare it everytime again.
toJSON
Converts the ButtonBuilder class to an object to make it a valid object for the Discord API. The function returns the same data as the data property.
Last updated