Class BaseUserContextMenu

java.lang.Object
com.dianxin.tori.api.commands.usercontext.BaseUserContextMenu
All Implemented Interfaces:
IUserContextMenu

public abstract class BaseUserContextMenu extends Object implements IUserContextMenu
An abstract base class for statically configured User 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.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseUserContextMenu(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 BaseUserContextMenu with explicit parameters.
    BaseUserContextMenu(String title, net.dv8tion.jda.api.JDA jda, IBotMeta meta, LegacyCommandBuilder builder)
    Constructs a statically configured BaseUserContextMenu using a LegacyCommandBuilder.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    execute(net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent event)
    The core execution logic of the user 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.UserContextInteractionEvent event, CommandReplyConfig replyConfig)
    Handles the lifecycle and validation of the user context menu execution.

    Methods inherited from class java.lang.Object

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

    • BaseUserContextMenu

      public BaseUserContextMenu(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 BaseUserContextMenu 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.
    • BaseUserContextMenu

      public BaseUserContextMenu(String title, net.dv8tion.jda.api.JDA jda, IBotMeta meta, LegacyCommandBuilder builder)
      Constructs a statically configured BaseUserContextMenu 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.UserContextInteractionEvent event, CommandReplyConfig replyConfig)
      Handles the lifecycle and validation of the user context menu execution. Validates all statically defined conditions before delegating to execute(UserContextInteractionEvent).
      Specified by:
      handle in interface IUserContextMenu
      Parameters:
      event - The UserContextInteractionEvent 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.UserContextInteractionEvent event)
      The core execution logic of the user context menu command. Developers must implement this method to define what the command actually does after passing all checks.
      Parameters:
      event - The valid UserContextInteractionEvent passed through all pre-execution checks.