'How to get the selected option in the Select Menu Interaction Event of JDA?
My question is how can I get the selected option, if in the SelectionMenuEvent event it doesn't have the method to get the option that the user selected from the menu.
My code:
@Override
public void execute(Member member, Message message) {
val menu = SelectionMenu.create("help.menu");
val command = this.loadAllCommand(message);
command.forEach(c -> menu.addOption(c.getName(), c.getPermission(), c.getDescription(), c.getEmoji()));
message.reply("```Diff\n" +
"+ List of my current commands" +
"\n```").setActionRow(menu.build()).queue();
}
// Event
@Override
public void onSelectionMenu(SelectionMenuEvent event) {
// get selected option of the menu
}
I looked at the SelectionMenuEvent class documentation, let me know if I missed something.
I am using JDA version 4.4.0_350.
Solution 1:[1]
You can use SelectMenuInteraction#getValues or SelectMenuInteraction#getSelectedOptions. The event implements this interface.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Minn |
