Interface EntitySelectMenuHandler


public interface EntitySelectMenuHandler
An interface that contains the method that should be executed when a user interacts with a EntitySelectMenu.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    handleEntitySelectMenu(net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent event, List<net.dv8tion.jda.api.entities.IMentionable> values)
    Method that must be overridden for all classes that handle EntitySelectInteraction All select menus that match the identifier will execute this class's implementation of the handleEntitySelectMenu method.
  • Method Details

    • handleEntitySelectMenu

      void handleEntitySelectMenu(@Nonnull net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent event, @Nonnull List<net.dv8tion.jda.api.entities.IMentionable> values)
      Method that must be overridden for all classes that handle EntitySelectInteraction All select menus that match the identifier will execute this class's implementation of the handleEntitySelectMenu method. This is best used with the ComponentIdBuilder.
       
           public class TestCommand extends SlashCommand implements EntitySelectMenuHandler {
      
           public TestCommand() {
               setCommandData(Commands.slash("test", "test description"));
           }
      
          @Override
          public void execute(SlashCommandInteractionEvent event) {
       		//Build your select menu here.
          }
      
          @Override
          public void handleEntitySelectMenu(EntitySelectInteractionEvent event, List<IMentionable> values) {
              for (IMentionable entity : values) {
                  event.getChannel().sendMessage(String.format("Mention: %s", entity.getAsMention())
              }
         }
       }
      
       
      In order for this to work, you manually have to configure the corresponding entity-select menu mappings like that:
      
       dih4JDA.addEntitySelectMenuMappings(IdMapping.of(new TestCommand(), "test-entity-select-menu"));
       
      Parameters:
      event - the EntitySelectInteractionEvent instance.
      values - the values that you could select.