Interface SelectMenuHandler


public interface SelectMenuHandler
Handler for select menu (dropdown) interactions.

Preferred approach: Use the @SelectMenuHandler annotation directly on methods in your @Plugin class:

@Plugin(name = "MyPlugin", version = "1.0.0", author = "Author")
public class MyPlugin {

    @SelectMenuHandler("myplugin:select:")
    public void handleSelect(StringSelectInteractionEvent event) {
        List<String> values = event.getValues();
        event.reply("You selected: " + String.join(", ", values)).queue();
    }
}

Alternative: Implement this interface and register via InteractionManager:


public class MySelectHandler implements SelectMenuHandler {
    @Override
    public String getSelectMenuIdPrefix() {
        return "myplugin:select:";
    }

    @Override
    public void handleStringSelect(StringSelectInteractionEvent event) {
        List<String> values = event.getValues();
        event.reply("You selected: " + String.join(", ", values)).queue();
    }
}

  • Method Summary

    Modifier and Type
    Method
    Description
    Get the select menu ID prefix this handler responds to.
    default void
    handleEntitySelect(net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent event)
    Handle entity select menu interaction.
    default void
    handleStringSelect(net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent event)
    Handle string select menu interaction.
  • Method Details

    • getSelectMenuIdPrefix

      String getSelectMenuIdPrefix()
      Get the select menu ID prefix this handler responds to.
      Returns:
      the select menu ID prefix
    • handleStringSelect

      default void handleStringSelect(net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent event)
      Handle string select menu interaction.

      Called when a user selects options from a string select menu (dropdown with predefined string options).

      Parameters:
      event - the string select interaction event
    • handleEntitySelect

      default void handleEntitySelect(net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent event)
      Handle entity select menu interaction.

      Called when a user selects entities (users, roles, channels, etc.) from an entity select menu.

      Parameters:
      event - the entity select interaction event