Package com.dianxin.tori.api.interaction
Class ModalRegistrar
java.lang.Object
com.dianxin.tori.api.interaction.ModalRegistrar
A registry class responsible for managing and routing Discord Modal interactions.
It stores registered modal handlers and delegates incoming events to the appropriate handler based on the Modal ID.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new ModalRegistrar for the specified bot. -
Method Summary
Modifier and TypeMethodDescriptionGets the base bot instance associated with this registrar.getJda()Gets the JDA instance associated with this registrar.@Nullable ModalRetrieves a registered Discord Modal by its custom ID.voidonModal(ModalInteractionEvent event) Processes an incoming modal submission event and routes it to the corresponding registered handler.voidregister(IModalHandler modalHandler) Registers a new modal handler into the registry.
-
Constructor Details
-
ModalRegistrar
Constructs a new ModalRegistrar for the specified bot.- Parameters:
bot- TheJavaDiscordBotinstance that owns this registrar.
-
-
Method Details
-
register
Registers a new modal handler into the registry.- Parameters:
modalHandler- TheIModalHandlerto register.
-
onModal
Processes an incoming modal submission event and routes it to the corresponding registered handler. If the ID is not found, an ephemeral error message is sent to the user.- Parameters:
event- TheModalInteractionEventtriggered by Discord.
-
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.
-
getModal
Retrieves a registered Discord Modal by its custom ID.- Parameters:
id- The custom ID of the modal to retrieve.- Returns:
- The
Modalif found, ornullif not registered.
-