Package com.dianxin.tori.api.interaction
Class ComponentRegistrar
java.lang.Object
com.dianxin.tori.api.interaction.ComponentRegistrar
A registry class responsible for managing and routing Discord UI Component interactions
such as Buttons, String Select Menus, and Entity Select Menus.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new ComponentRegistrar for the specified bot. -
Method Summary
Modifier and TypeMethodDescriptionGets the base bot instance associated with this registrar.@Nullable net.dv8tion.jda.api.components.selections.EntitySelectMenuRetrieves a registered Entity Select Menu by its custom ID.net.dv8tion.jda.api.JDAgetJda()Gets the JDA instance associated with this registrar.@Nullable net.dv8tion.jda.api.components.selections.StringSelectMenuRetrieves a registered String Select Menu by its custom ID.voidonButton(net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent event) Processes an incoming button click event and routes it to the corresponding registered handler.voidonEntity(net.dv8tion.jda.api.events.interaction.component.EntitySelectInteractionEvent event) Processes an incoming entity select menu event and routes it to the corresponding registered handler.voidonString(net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent event) Processes an incoming string select menu event and routes it to the corresponding registered handler.voidregister(IButtonHandler handler) Registers a new button handler into the registry.voidregister(IEntitySelectMenuHandler handler) Registers a new entity select menu handler into the registry.voidregister(IStringSelectMenuHandler handler) Registers a new string select menu handler into the registry.
-
Constructor Details
-
ComponentRegistrar
Constructs a new ComponentRegistrar for the specified bot.- Parameters:
bot- TheJavaDiscordBotinstance that owns this registrar.
-
-
Method Details
-
register
Registers a new entity select menu handler into the registry.- Parameters:
handler- TheIEntitySelectMenuHandlerto register.
-
register
Registers a new string select menu handler into the registry.- Parameters:
handler- TheIStringSelectMenuHandlerto register.
-
register
Registers a new button handler into the registry.- Parameters:
handler- TheIButtonHandlerto 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- TheEntitySelectInteractionEventtriggered 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- TheStringSelectInteractionEventtriggered 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- TheButtonInteractionEventtriggered by Discord.
-
getJda
public net.dv8tion.jda.api.JDA getJda()Gets the JDA instance associated with this registrar.- Returns:
- The
JDAinstance.
-
getBaseBot
Gets the base bot instance associated with this registrar.- Returns:
- The
JavaDiscordBotinstance.
-
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
StringSelectMenuif found, ornullif 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
EntitySelectMenuif found, ornullif not registered.
-