Components & Interactions
editSelectMenu
$editSelectMenu
The $editSelectMenu[] function modifies an existing string select menu, either in the response being built or on a message sent by the bot.
Syntax
$editSelectMenu[customId;minValues;maxValues;(placeholder);(messageID)]
Parameters
| Parameter | Description |
|---|---|
customId |
The custom ID of the select menu to modify (1 to 100 characters). |
minValues |
Required. Minimum number of selections (integer from 0 to 25). |
maxValues |
Required. Maximum number of selections (integer from 1 to 25). |
placeholder |
(Optional) Placeholder text (0 to 150 characters); empty by default. |
messageID |
(Optional) ID of an existing message sent by the bot (a positive integer, otherwise “Invalid message ID.”). If omitted or empty, the menu is searched in the response being built and, in the script run for a click, in the clicked message. |
Return value
An empty string. The select menu is modified.
Behavior
- The targeted menu must be a string select menu that exists, otherwise the error “Component
not found." is raised. User, role, mentionable and channel select menus cannot be edited with this function. - Without
messageID, the menu is first searched among the components added earlier in the same script. In the script run for a click on a button or a menu, if it is not there, the clicked message is edited. - With
messageID, the engine reads that message’s components and applies the edit when the response is flushed. Only messages sent by the bot, in the current channel, can be edited (Only bot-authored message components can be edited.); an ephemeral message cannot be edited by its ID. - Components V2 messages can be edited: the menu is found at any depth and the layout of the message is kept.
minValuesmust be ≤maxValues(“Minimum cannot exceed maximum.”), andmaxValuescannot be higher than the number of options of the menu (Select menu option count does not support its selection bounds.).- The placeholder is always replaced (empty if the argument is omitted).
- The options of the menu are not changed; use
$editSelectMenuOption[]for that.
Examples
Update after selection
Workflow with the event interactionCreate and the custom ID filter (customIdFilter) langMenu. $customID only exists in the script run for the click, never in the slash command. Without messageID, the clicked message is edited.
$editSelectMenu[langMenu;0;1;Language chosen!]
With a message ID:
$editSelectMenu[langMenu;0;1;Language chosen!;123456789012345678]
Edit a menu of the response being built
$newSelectMenu[levelMenu;1;1;Level]
$addSelectMenuOption[levelMenu;Easy;easy;;no]
$addSelectMenuOption[levelMenu;Hard;hard;;no]
$editSelectMenu[levelMenu;0;1;Pick a level (optional)]
Choose a level
Reset a dynamic select menu
$editSelectMenu[categoryMenu;1;3;Select a category;123456789012345678]
Notes
- To modify the menu options, use
$editSelectMenuOption[]. maxValues=1creates a single-choice menu,>1a multi-choice menu.
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.