Class ModalRegistrar

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

public class ModalRegistrar extends Object
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

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

    Modifier and Type
    Method
    Description
    Gets the base bot instance associated with this registrar.
    net.dv8tion.jda.api.JDA
    Gets the JDA instance associated with this registrar.
    @Nullable net.dv8tion.jda.api.modals.Modal
    Retrieves a registered Discord Modal by its custom ID.
    void
    onModal(net.dv8tion.jda.api.events.interaction.ModalInteractionEvent event)
    Processes an incoming modal submission event and routes it to the corresponding registered handler.
    void
    register(IModalHandler modalHandler)
    Registers a new modal handler into the registry.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ModalRegistrar

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

    • register

      public void register(IModalHandler modalHandler)
      Registers a new modal handler into the registry.
      Parameters:
      modalHandler - The IModalHandler to register.
    • onModal

      public void onModal(net.dv8tion.jda.api.events.interaction.ModalInteractionEvent event)
      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 - The ModalInteractionEvent 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.
    • getModal

      @Nullable public @Nullable net.dv8tion.jda.api.modals.Modal getModal(String id)
      Retrieves a registered Discord Modal by its custom ID.
      Parameters:
      id - The custom ID of the modal to retrieve.
      Returns:
      The Modal if found, or null if not registered.