Skip to content

Buttons

This Section will cover how to create a button, multiple buttons and also detect and handle button inputs.

Important

  • Each Button needs a Custom ID to detect when it was Pressed
  • You can get a Emoji on Windows using Win+.

Create One Button

This Construction will trigger when the !buttons Command was run, that will create and send the button with the Send Message(Components) Block.
Image

Create Multiple Buttons

We are going to use the same command like the first one and just add more Create Button Blocks. In Combination with Create Button Row
https://i.imgur.com/bOXExvC.png

Detect and handle a Button Press

You can use the Interaction Event to detect a Button Press using the Custom ID. Also to get the Current Time and Date you use the Create Date Block and using the Format Date Block you can get the Date in a Text Type. To now send a message back to the User that used the Button, you can use the Reply to Interaction Block.
(Ephemeral means only visible to the user)
https://i.imgur.com/9imoEyd.png

Testing Everything

When you launch the bot you can now use the example command that was created, and with that the 3 Buttons should be sent. When you now click on a Button the message you reply! Button Run

Your Turn

Since you now know how to handle one button, you can do the same for the other example buttons and try to send a Message Back!

Still Issues or Questions?

If you have Issues or any questions you can always ask on the Discord Bot Builder Discord, or send me a DM: xcrafttm!