Class ModalRegistrar

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

@ReleasedSince("26.5.123") 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 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(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 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 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.