In this section, you'll learn how to use the button components.
Buttons can have different styles (background colors).
Here, are all possible values for
style function argument.
linkstyle is used, the button won't send any interactions!
The image was taken from Discord Docs
There are 2 types of buttons :
When an interactive button is pressed, it sends an interaction which can be used together with
Every interactive button has an
ID. If you create
$onInteraction[ID] callback, it will get triggered when the button with the same
ID is pressed.
Interactive buttons can use every
Link buttons don't send any interactions. When they're pressed they forward the user to a website.
Link buttons have to set their
style argument value to
Buttons can be added to a new message or already existing message.
$addButton[New row;Button ID/URL;Label;Style;(Disabled;Emoji;Message ID)]
new row- If set to
yesthe button will appear in a new row. If it's set to
nothe button will appear in the same row as a previous button. Check examples below.
📝 A message can have a maximum of 25 buttons (5 rows of 5 buttons).
button ID/url- Depending on a button type, you either set it to
interactionIDwhich is then used in
URLif it's link button.
label- It's the text value visible on a button
style- It's used to specify the button's background color. If the button has a link/url you have to set this to
link. Check this section for more details.
disabled- If set to
yesthe button can't be pressed. Defaults as
emoji- Adds an emoji inside the button. Emojis have to be either pasted as unicode or be in this format
<:emoji name:emoji ID>. (Optional)
message ID- Adds a button to the provided message ID. It's important to note that provided message ID author has to be the bot. (Optional)
Note: Interactive buttons can't have duplicated
ID's in the same message. So for example, you can't have two buttons with the ID set to
urlis used in
interaction ID or urlargument, it has to start with
$editButton[Button ID/URL;Label;Style;(Disabled;Emoji;Message ID)]
Arguments work exactly the same way as in $addButton function.
Button ID/URL is used for finding the button.
Removing button from a message can be done using these three functions :
Note: The last argument in
$addButtonis empty because we don't want emojis for this example
Note: ID provided in
$onInteractionis the same as the one provided in
$addButtonfrom this section
yesis being used for the
new rowargument so that the button would appear in the next row. Check the output below.