Shandler
  • Shandler
  • Information
    • Basic Usage
    • SHClient and Interaction
    • Deleting Commands
  • Interactions
    • Methods
  • Buttons
    • Getting Started with Buttons
    • Dropdowns
    • buttonClick Event
    • Buttons Documentation
Powered by GitBook
On this page
  • Button Clicks
  • Replying to buttons
  • Updating buttons
  • Examples
  • Buttons
  • Dropdowns

Was this helpful?

  1. Buttons

buttonClick Event

PreviousDropdownsNextButtons Documentation

Last updated 3 years ago

Was this helpful?

Button Clicks

When someone clicks on a button or uses a dropdown, it will fire an event called 'buttonClick'.

client.on('buttonClick', async (button) => {
});

Replying to buttons

We can reply when a button is clicked using .reply().

button.reply("");

If needed, you are able to add embeds, flags, attachments, and type in the reply. Check .

Updating buttons

We can edit the original message that had the buttons using .update().

button.update("");

If needed, you are able to add embeds, flags, attachments, and type in the reply. Check .

Examples

Buttons

client.on('buttonClick', async (button) => {
    if (button.data.custom_id === "1") {

        button.reply("Heya!"); //Reply to the interaction.

    } else if (button.data.custom_id === "2") {

        button.update("Edited the button :)"); //This will edit the original message. 

    } else if (button.data.custom_id === "3") {

        button.reply("Heya!", { flags: 64 }); //This will reply to the interaction with an ephemeral message. 

    } else if (button.data.custom_id === "4") {

        let cmp = [
            {
                "type": 1, "components": [
                    { "type": 2, "style": 1, "label": "Button 1", "custom_id": "3" },
                ]
            }
        ];

        button.update("Buttons!", { components: cmp });

    };
});

Dropdowns

client.on('buttonClick', async (button) => {
    if (button.data.custom_id === "dropdown1") {

        if (button.data.values[0] === "hmmm") {

            button.reply(`🤔`)

        } else if (button.data.values[0] === "test") {

            button.reply(`Tests`)

        }
    };
});

Here is an example of how to check for button IDs and how to handle them. ****

Here is an example of how to check for dropdown information and how to handle them. ****

Example
Example
Methods
Methods