Class ModernBaseMessageContextMenu

java.lang.Object
com.dianxin.tori.api.commands.messagecontext.ModernBaseMessageContextMenu
All Implemented Interfaces:
IMessageContextMenu

public abstract class ModernBaseMessageContextMenu extends Object implements IMessageContextMenu
An abstract base class for modern Message Context Menus.

Subclasses extending this class must be annotated with ContextMenu to provide the necessary metadata (like the interaction name) to the CommandRegistrar. Execution constraints are handled dynamically via class-level annotations.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ModernBaseMessageContextMenu(net.dv8tion.jda.api.JDA jda, IBotMeta meta)
    Constructs a new ModernBaseMessageContextMenu.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    execute(net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event)
    The core execution logic of the message context menu command.
    protected net.dv8tion.jda.api.JDA
    Retrieves the JDA instance associated with this command.
    protected org.slf4j.Logger
    Retrieves the logger instance for the current command.
    final void
    handle(net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event, CommandReplyConfig replyConfig)
    Handles the lifecycle and validation of the message context menu execution.

    Methods inherited from class java.lang.Object

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

    • ModernBaseMessageContextMenu

      public ModernBaseMessageContextMenu(net.dv8tion.jda.api.JDA jda, IBotMeta meta)
      Constructs a new ModernBaseMessageContextMenu.
      Parameters:
      jda - The JDA instance running this command.
      meta - The IBotMeta containing the bot's metadata.
  • Method Details

    • getLogger

      protected org.slf4j.Logger getLogger()
      Retrieves the logger instance for the current command. * @return The Logger instance.
    • getJda

      protected net.dv8tion.jda.api.JDA getJda()
      Retrieves the JDA instance associated with this command. * @return The JDA instance.
    • handle

      public final void handle(net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event, CommandReplyConfig replyConfig)
      Handles the lifecycle and validation of the message context menu execution. Parses the command's class annotations to enforce restrictions before delegating to execute(MessageContextInteractionEvent).
      Specified by:
      handle in interface IMessageContextMenu
      Parameters:
      event - The MessageContextInteractionEvent triggered by Discord.
      replyConfig - The configuration used for custom error or rejection messages.
    • execute

      protected abstract void execute(net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event)
      The core execution logic of the message context menu command. Developers must implement this method to define what the command actually does after passing all checks.
      Parameters:
      event - The valid MessageContextInteractionEvent passed through all pre-execution checks.