Slash Command

Introduction

triggers when a user uses a slash command. This needs to be a slash command from the bot.

Creating a slash command

In this example we will create an /avatar command, that shows the user's avatar

Steps

  1. Go to dashboard, your server page, click on Slash Command Builder

  2. Click Create

  3. Fill the slash name and description

  4. To add user option, to the slash, select from the option menu

  5. Select the User option (make sure background is blue)

  6. Fill the option name, description, remember this name, we will use it later

  7. Click Deploy Command/Save

  8. Create a new custom command, select type to be Slash Command and select your slash command from the dropdown in Trigger

  9. Set the code to be executed when the slash command is used

Code
    $let[user_id;$getOption[user]]
    $interactionReply[
        {title:Avatar of $usertag[$user_id]}
        {image:$userAvatar[$user_id]}
    ]
  1. go to your server and use the command as follows:

Output

Code Explanation

Retrieving the option from user

When a user uses the command like in Step 10, we can retrieve the option through the $getOption function:

$getOption[option name]

In our example option name is user from step 6
then the user id will be stored in a temporary variable nameduser_id using $let, this way we can recall it later in the code through $user_id:

    $let[user_id;$getOption[user]]

Sending Message

Next, to send a message with $interactionReply[message]
Here we will send an embed with a title and image using {title} and {image} Curl Message Format:

$interactionReply[
    {title:Embed Title}
    {image:Embed Image}
]
  1. In title we want to set it to: Avatar of Mido#1234
    To get the username Mido#1234 we will use $userTag[user id], to specifiy the user we will use $user_id:
Avatar of $userTag[$user_id]
  1. In Image to retrieve the user avatar, we will use $userAvatar[user id]:
$userAvatar[$user_id]

Whole code:

    $let[user_id;$getOption[user]]
    $interactionReply[
        {title:Avatar of $usertag[$user_id]}
        {image:$userAvatar[$user_id]}
    ]

Example 2: Sending Private Message

Let's modify the previous code, to make him reply in private to user instead like this:

$interactionReply accept 2 inputs by default: message, ephemeral
in the previous example we only used the first message, and 2nd input was by default no
To send the message in private we have to set the 2nd input ephemeral to yes

That's it, Save and test it out

Output