Class ComponentRegistrar

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

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 Summary

    Constructors
    Constructor
    Description
    Constructs a new ComponentRegistrar for the specified bot.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the base bot instance associated with this registrar.
    @Nullable net.dv8tion.jda.api.components.selections.EntitySelectMenu
    Retrieves a registered Entity Select Menu by its custom ID.
    net.dv8tion.jda.api.JDA
    Gets the JDA instance associated with this registrar.
    @Nullable net.dv8tion.jda.api.components.selections.StringSelectMenu
    Retrieves a registered String Select Menu by its custom ID.
    void
    onButton(net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent event)
    Processes an incoming button click event and routes it to the corresponding registered handler.
    void
    onEntity(net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent event)
    Processes an incoming entity select menu event and routes it to the corresponding registered handler.
    void
    onString(net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent event)
    Processes an incoming string select menu event and routes it to the corresponding registered handler.
    void
    Registers a new button handler into the registry.
    void
    Registers a new entity select menu handler into the registry.
    void
    Registers a new string select menu handler into the registry.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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(net.dv8tion.jda.api.events.interaction.component.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(net.dv8tion.jda.api.events.interaction.component.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(net.dv8tion.jda.api.events.interaction.component.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 net.dv8tion.jda.api.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 net.dv8tion.jda.api.components.selections.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 net.dv8tion.jda.api.components.selections.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.