Annotation Interface StringMenu
Methods annotated with StringMenu will be registered as a StringSelectMenu at startup.
Therefore, the method must be declared inside a class that is annotated with
Interaction.
Furthermore, the method signature has to meet the following conditions:
- First parameter must be of type
ComponentEvent - Second parameter must be of type
List<String>
You can reply with a string select menu by calling MessageReply.components(Component...).
Example:
@MenuOption(label= "Pizza", value = "pizza")
@MenuOption(label= "Hamburger", value = "hamburger")
@MenuOption(label= "Sushi", value = "Sushi")
@StringMenu("What's your favourite food?")
public void onMenu(ComponentEvent event, List<String> choices) { ... }
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintThe maximum amount of values a user can select.intThe minimum amount of values a user has to select.booleanConfigure whether the user must populate this select menu if inside a Modal.intThe uniqueId of this component.Configure the placeholder which is displayed when no selections have been made yet.
-
Element Details
-
value
String valueConfigure the placeholder which is displayed when no selections have been made yet.- Returns:
- the placeholder which is displayed when no selections have been made yet
- Default:
""
-
minValue
int minValueThe minimum amount of values a user has to select.
Default:
1The minimum must not exceed the amount of available options.
- Returns:
- the minimum amount of values a user has to select
- Default:
1
-
maxValue
int maxValueThe maximum amount of values a user can select.
Default:
1The maximum must not exceed the amount of available options.
- Returns:
- the maximum amount of values a user can select
- Default:
1
-
uniqueId
int uniqueIdThe uniqueId of this component. Must be greater than 0. Default value is-1which will result in Discord auto assigning an id.- Default:
-1
-
required
boolean requiredConfigure whether the user must populate this select menu if inside a Modal.
This defaults to
truein Modals when unset.This attribute is completely separate from the value range, for example, you can have an optional select menu with the range set to
[2 ; 5], meaning you accept either 0 options, or, at least 2 but at most 5.This only has an effect in Modals!
- Returns:
- Whether this menu is required
- Default:
true
-