Select Menu
In this section you'll learn how to use the select menu component.
Creating a Select Menu
$newSelectMenu[Menu ID;Min;Max;(Placeholder;Message ID)]
Menu ID
- it's used for$onInteraction[ID]
callback. It works the same way as buttons.Min
- minimum amount of values that can be selected.Max
- maximum amount of values that can be selected.Placeholder
- it's a text that appears if no option is selected.Message ID
- ID of a message that should have select menu added to it. By default it's the bot's response.
Adding an Option
$addSelectMenuOption[Menu option ID;Label;Value;Description;(Default;Emoji;Message ID)]
Menu option ID
- it has to be the same as the ID used in$newSelectMenu[]
.Label
- the name of the option.Value
- it's the data that gets passed to$onInteraction[]
callback. The value has to be unique in the select menu!Description
- it shows up under thelabel
.Default
- should the option be selected by default. There can be only one default option!Emoji
- it shows up next to thelabel
.Message ID
- same as in$newSelectMenu[]
.
Example
Select Menu Code
$newSelectMenu[Example;1;1;Choose some option]
$addSelectMenuOption[Example;First;first-option;The first option]
$addSelectMenuOption[Example;Second;second-option;The second option]
$addSelectMenuOption[Example;Third;third-option;The third option]
Interaction Code
$onInteraction[Example]
$if[$message==first-option]
You have chosen the first option
$elseif[$message==second-option]
You have chosen the second option
$elseif[$message==third-option]
You have chosen the third option
$endif
Usage
Multi-Select Menu
In the Select Menu you can choose not only one option, but several at once.
You could understand this by the presence of arguments Min
and Max
.
Example
Select Menu Code
Here we will change the argument
Max
to 3.
$newSelectMenu[Example;1;3;Choose some option]
$addSelectMenuOption[Example;First;first-option;The first option]
$addSelectMenuOption[Example;Second;second-option;The second option]
$addSelectMenuOption[Example;Third;third-option;The third option]
Interaction Code
$if[$checkContains[$message;first-option]==true]
$addCmdReactions[1️⃣]
$endif
$if[$checkContains[$message;second-option]==true]
$addCmdReactions[2️⃣]
$endif
$if[$checkContains[$message;third-option]==true]
$addCmdReactions[3️⃣]
$endif
If we choose several options, several reactions will be added.
Usage
Editing a Select Menu
You can edit Select Menu, as well as options in this menu.
$editSelectMenu
Usage
$editSelectMenu[Menu ID;Min;Max;(Placeholder;Message ID)]
$editSelectMenuOption
Usage
$editSelectMenuOption[Menu option ID;Label;Value;Description;(Default;Emoji;Message ID)]
As you can notice, the arguments are exactly the same.
Example
Select Menu Code
$newSelectMenu[Example;1;1;Choose some option]
$addSelectMenuOption[Example;First;first-option;The first option]
$addSelectMenuOption[Example;Second;second-option;The second option]
$addSelectMenuOption[Example;Third;third-option;The third option]
Interaction Code
Example 1
$editSelectMenuOption[Example;First;first-option;The first option;no;1️⃣]
$editSelectMenuOption[Example;Second;second-option;The second option;no;2️⃣]
$editSelectMenuOption[Example;Third;third-option;The third option;no;3️⃣]
We just added emoji to our options after choosing (any) option.
Example 2
$editSelectMenu[Example;1;1;Choose some option 😀]
$addSelectMenuOption[Example;First;first-option;The first option]
$addSelectMenuOption[Example;Second;second-option;The second option]
$addSelectMenuOption[Example;Third;third-option;The third option]
We just changed the placeholder of our Select Menu after choosing (any) option.