Class BaseMessageContextMenu

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

public abstract class BaseMessageContextMenu extends Object implements IMessageContextMenu
An abstract base class for statically configured Message Context Menus. This class relies on constructor parameters or a builder to define its metadata and execution constraints (such as required permissions or channel restrictions) instead of class-level annotations, ensuring optimized performance.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseMessageContextMenu(String title, net.dv8tion.jda.api.JDA jda, IBotMeta meta, boolean isDefer, boolean guildOnly, boolean ownerOnly, boolean privateChannelOnly, boolean directMessageOnly, List<net.dv8tion.jda.api.Permission> permissionsRequired, List<net.dv8tion.jda.api.Permission> selfPermissionsRequired, boolean isDebug)
    Constructs a statically configured BaseMessageContextMenu with explicit parameters.
    BaseMessageContextMenu(String title, net.dv8tion.jda.api.JDA jda, IBotMeta meta, LegacyCommandBuilder builder)
    Constructs a statically configured BaseMessageContextMenu using a LegacyCommandBuilder.
  • 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.
    Retrieves the title of the context menu as shown in the Discord client.
    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
  • Field Details

    • logger

      protected final org.slf4j.Logger logger
  • Constructor Details

    • BaseMessageContextMenu

      public BaseMessageContextMenu(String title, net.dv8tion.jda.api.JDA jda, IBotMeta meta, boolean isDefer, boolean guildOnly, boolean ownerOnly, boolean privateChannelOnly, boolean directMessageOnly, List<net.dv8tion.jda.api.Permission> permissionsRequired, List<net.dv8tion.jda.api.Permission> selfPermissionsRequired, boolean isDebug)
      Constructs a statically configured BaseMessageContextMenu with explicit parameters.
      Parameters:
      title - The name or title of the context menu displayed in Discord.
      jda - The JDA instance running this command.
      meta - The IBotMeta containing the bot's metadata.
      isDefer - Whether the reply should be automatically deferred.
      guildOnly - Whether the command is restricted to guilds (servers).
      ownerOnly - Whether the command is restricted strictly to the bot owner.
      privateChannelOnly - Whether the command is restricted to private channels.
      directMessageOnly - Whether the command is restricted to direct messages.
      permissionsRequired - A list of permissions required by the user invoking the command.
      selfPermissionsRequired - A list of permissions required by the bot itself.
      isDebug - Whether to log debug information upon execution.
    • BaseMessageContextMenu

      public BaseMessageContextMenu(String title, net.dv8tion.jda.api.JDA jda, IBotMeta meta, LegacyCommandBuilder builder)
      Constructs a statically configured BaseMessageContextMenu using a LegacyCommandBuilder.
      Parameters:
      title - The name or title of the context menu displayed in Discord.
      jda - The JDA instance running this command.
      meta - The IBotMeta containing the bot's metadata.
      builder - The configured LegacyCommandBuilder containing execution constraints.
  • Method Details

    • getJda

      protected net.dv8tion.jda.api.JDA getJda()
      Retrieves the JDA instance associated with this command.
      Returns:
      The JDA instance.
    • getTitle

      public String getTitle()
      Retrieves the title of the context menu as shown in the Discord client.
      Returns:
      The title string.
    • getLogger

      protected org.slf4j.Logger getLogger()
      Retrieves the logger instance for the current command.
      Returns:
      The Logger 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. Validates all statically defined conditions 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.