Skip to content

Interaction Examples

javis86 edited this page Sep 14, 2024 · 7 revisions

Creating Slash Commands

Please refer to discordCommandManager

Creating components

Adding components to a message creates a interaction between someone and the bot. All the components are created inside a Row Component.

  • Button component
[
    {
        "type": 1,
        "components": [
            {
                "type": 2,
                "label": "Option 1",
                "style": 3,
                "custom_id": "click_opt1"
            },
            {
                "type": 2,
                "label": "Option 2",
                "style": 4,
                "custom_id": "click_opt2"
            }
        ]
    }
]
  • Flow adding components

Flow example

Responding to button and select menu

Flow example

Responding to commands

Flow example

Responding to commands with ephemeral response

In this example, the node replies the command with ephemeral flag and then edits it.

Flow example

Responding to autocomplete

Autocomplete commands has two parts. The first one is to respond when discord filters options when the command was not fired. The second one is when option is selected and command is fired.

let newMessage = {};
newMessage.action = "respondAutocomplete";
newMessage.autoCompleteChoices = ["Juan", "Javier", "Hernan"];
newMessage.interactionId = msg.payload.id;
return newMessage;

Flow example

Clone this wiki locally