Buttons
In this section, you’ll learn how to use the button component.
Content
Functions Used > Button Style > Button Type > $addButton[] > $editButton[] > $removeButtons > $removeButtons[] > $removeComponent[] > Create Interaction
Functions Used
Support Callbacks Used
Button Style
Buttons can have different styles (background colors).
Here, are all possible values for the style function argument.
primary- Blue buttonsecondary- Gray buttonsuccess- Green buttondanger- Red buttonlink- Redirect button
If
linkstyle is used, the button won’t send any interactions!
Button Type
There are 2 types of buttons : interactive and link.
When an interactive button is pressed, it sends an interaction which can be used together with $onInteraction[ID].
Every interactive button has an ID. A $onInteraction[ID] callback, will only get triggered when the button with the same ID is pressed.
Interactive buttons can use every style except link.
Link buttons don’t send any interactions. When they’re pressed they forward the user to a website.
Link buttons need to set their
styleargument value tolink.
$addButton
Adds a button to the response message.
Syntax
$addButton[New row?;Interaction ID/url;Label;Style;(Disable?;Emoji;Message ID)]
Parameters
-
New row?(Type: Bool || Flag: Required): If set toyesthe button will appear in a new row. If it’s set tonothe button will appear in the same row as a previous button.A message can have a maximum of 25 buttons (5 rows of 5 buttons).
-
Interaction ID/URL(Type: String, URL || Flag: Required): Depending on the button type, you either set it to anInteraction IDwhich is then used in the$onInteraction[Interaction ID]or$onInteractioncallback or aURLif it’s a link button.
You don’t need
$onInteraction/$onInteraction[]for URL.
Label(Type: String || Flag: Emptiable): The text visible on the button.Style(Type: Enum || Flag: Required): It’s used to specify the button’s background color. If the button has a link/url you have to set this value tolink. Check this section for more details.Disable?(Type: Bool || Flag: Vacantable): If set toyesthe button can’t be pressed. Defaults asno.Emoji(Type: Emoji || Flag: Vacantable): Adds an emoji inside the button. Emojis have to be either pasted as unicode or be in the following format<:emoji name:emoji ID>.message ID(Type: Snowflake || Flag: Vacantable): Adds a button to the provided message ID. It’s important to note that provided message ID author has to be the bot.
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 totest.
If
URLis used inInteraction ID/urlargument, it has to start withhttp://orhttps://
Example
$nomention
Hello
$addButton[no;test;Say hello!;primary;no;]
$editButton
Edits an already existing button.
Syntax
$editButton[Interaction ID/URL;Label;Style;(Disable?;Emoji;Message ID)]
Parameters
Interaction ID/URL(Type: String, URL || Flag: Required): Depending on the button type, you either set it to anInteraction IDwhich is then used in the$onInteraction[Interaction ID]callback or aURLif it’s a link button.Label(Type: String || Flag: Emptiable): The text visible on the button.Style(Type: Enum || Flag: Required): It’s used to specify the button’s background color. If the button has a link/url you have to set this value tolink. Check this section for more details.Disable?(Type: Bool || Flag: Vacantable): If set toyesthe button can’t be pressed. Defaults asno. (Optional)Emoji(Type: Emoji || Flag: Vacantable): Edits an emoji inside the button. Emojis have to be either pasted as unicode or be in the following format<:emoji name:emoji ID>. (Optional)Message ID(Type: Snowflake || Flag: Vacantable): Edits a button in a message with the provided ID. It’s important to note that provided message ID author has to be the bot. (Optional)
Example
Trigger: $onInteraction[test]
$nomention
$username said hello!
$editButton[test;Say hello!;danger;yes;]
$removeButtons
Removes all buttons from the triggered message.
Syntax
$removeButtons
Example
Trigger: $onInteraction[test]
$nomention
$username removed all buttons from this message.
$removeButtons
$removeButtons[]
Removes all buttons from the specified message.
Syntax
$removeButtons[Message ID]
Parameters
Message ID(Type: Snowflake || Flag: Required): Removes buttons from the message with the provided ID. It’s important to note that provided message ID author has to be the bot.
Example
$nomention
$username removed all buttons from the specified message ID.
$removeButtons[$message]
$removeComponent
Removes a certain component from a message.
Syntax
$removeComponent[Interaction ID/URL;(Message ID)]
This function supports select-menu and button.
Parameters
Interaction ID/URL(Type: String || Flag: Required): The interaction ID of the button, to remove from the message.Message ID(Type: Snowflake || Flag: Vacantable): Removes the button from the message with the provided ID. It’s important to note that provided message ID author has to be the bot. (Optional)
Example
$nomention
$username successfully removed the button!
$removeComponent[test;$message]


Create interaction
Example with $onInteraction[] callback:
- Create two commands with
!exampleand$onInteraction[test]triggers. - Paste the following code:
Code for the command with the
!exampletrigger:
$nomention
Click the button below!
$addButton[no;test;Click;primary]
$addButton[no;button;Button disabled;secondary;yes]
$addButton[yes;https://botdesignerdiscord.com/;Link;link]
Code for the command with the $onInteraction[test] trigger:
$nomention
$editButton[test;Clicked;danger;yes]
$sendMessage[$username hello!]
Note that the interaction ID provided in
$onInteraction[]is the same as the one provided in$addButton[]In
$addButton[],yesis being used for thenew row?argument so that the button would appear in the next row.
- Execute command
!example

Example with $onInteraction callback:
- Create two commands with
!exampleand$onInteractiontriggers. - Paste the following code:
Code for the command with the
!exampletrigger:
$nomention
Click the button below!
$addButton[no;test;Click;primary]
$addButton[no;button;Button disabled;secondary;yes]
$addButton[yes;https://botdesignerdiscord.com/;Link;link]
Code for the command with the $onInteraction trigger:
$nomention
$if[$customID==test]
$editButton[test;Clicked;danger;yes]
$sendMessage[$username hello!]
$endif
Note that the interaction ID returned by
$customIDwill be the same as the one provided in$addButton[]In
$addButton[],yesis being used for thenew row?argument so that the button would appear in the next row.
- Execute command
!example

How
$onInteractionor$onInteraction[]works?