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 /avatar command, that show user avatar on request

Steps

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

  2. Click Create

  3. Fill the slash name and description, remember this name, we will use it later

  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 Trigger to be avatar (the name from step 3)

  9. Set the code to be (will be explained in next section)

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 fellow:

Output

Code Explanation

Retrieving the option from user

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

$getOption[option name]

In our example option name is user from step 6
then the user id will be stored in user_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]
but here we will send an embed with title and image, using {title}, {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 image, 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