Class ComponentRegistrar

java.lang.Object
com.dianxin.tori.api.interaction.ComponentRegistrar

@ReleasedSince("26.5.123") public class ComponentRegistrar extends Object
A registry class responsible for managing and routing Discord UI Component interactions such as Buttons, String Select Menus, and Entity Select Menus.
  • Constructor Details

    • ComponentRegistrar

      public ComponentRegistrar(JavaDiscordBot bot)
      Constructs a new ComponentRegistrar for the specified bot.
      Parameters:
      bot - The JavaDiscordBot instance that owns this registrar.
  • Method Details

    • register

      public void register(IEntitySelectMenuHandler handler)
      Registers a new entity select menu handler into the registry.
      Parameters:
      handler - The IEntitySelectMenuHandler to register.
    • register

      public void register(IStringSelectMenuHandler handler)
      Registers a new string select menu handler into the registry.
      Parameters:
      handler - The IStringSelectMenuHandler to register.
    • register

      public void register(IButtonHandler handler)
      Registers a new button handler into the registry.
      Parameters:
      handler - The IButtonHandler to register.
    • onEntity

      public void onEntity(EntitySelectInteractionEvent event)
      Processes an incoming entity select menu event and routes it to the corresponding registered handler.
      Parameters:
      event - The EntitySelectInteractionEvent triggered by Discord.
    • onString

      public void onString(StringSelectInteractionEvent event)
      Processes an incoming string select menu event and routes it to the corresponding registered handler.
      Parameters:
      event - The StringSelectInteractionEvent triggered by Discord.
    • onButton

      public void onButton(ButtonInteractionEvent event)
      Processes an incoming button click event and routes it to the corresponding registered handler.
      Parameters:
      event - The ButtonInteractionEvent triggered by Discord.
    • getJda

      public JDA getJda()
      Gets the JDA instance associated with this registrar.
      Returns:
      The JDA instance.
    • getBaseBot

      public JavaDiscordBot getBaseBot()
      Gets the base bot instance associated with this registrar.
      Returns:
      The JavaDiscordBot instance.
    • getStringSelectMenu

      @Nullable public @Nullable StringSelectMenu getStringSelectMenu(String id)
      Retrieves a registered String Select Menu by its custom ID.
      Parameters:
      id - The custom ID of the menu to retrieve.
      Returns:
      The StringSelectMenu if found, or null if not registered.
    • getEntitySelectMenu

      @Nullable public @Nullable EntitySelectMenu getEntitySelectMenu(String id)
      Retrieves a registered Entity Select Menu by its custom ID.
      Parameters:
      id - The custom ID of the menu to retrieve.
      Returns:
      The EntitySelectMenu if found, or null if not registered.