Class BaseCommand

java.lang.Object
com.dianxin.tori.api.commands.slash.BaseCommand
All Implemented Interfaces:
ISlashCommand

public abstract class BaseCommand extends Object implements ISlashCommand
A statically optimized version of ModernBaseCommand. Completely removes the Annotation scanning (Reflection) process to ensure maximum execution speed, helping to prevent Discord's 3-second "Bot is thinking" timeout error.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseCommand(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 BaseCommand.
    BaseCommand(net.dv8tion.jda.api.JDA jda, IBotMeta meta, LegacyCommandBuilder builder)
    Constructs a BaseCommand using the LegacyCommandBuilder.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    execute(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event)
    The core execution logic of the command.
    protected net.dv8tion.jda.api.JDA
     
    protected org.slf4j.Logger
     
    final void
    handle(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event, CommandReplyConfig replyConfig)
    Handles the lifecycle and validation of the command execution.

    Methods inherited from class java.lang.Object

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

    • BaseCommand

      public BaseCommand(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 BaseCommand.
      Parameters:
      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.
      ownerOnly - Whether the command is restricted 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.
      selfPermissionsRequired - A list of permissions required by the bot.
      isDebug - Whether to log debug information when executed.
    • BaseCommand

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

    • getLogger

      protected org.slf4j.Logger getLogger()
      Returns:
      The logger instance for the current command.
    • getJda

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

      public final void handle(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event, CommandReplyConfig replyConfig)
      Handles the lifecycle and validation of the command execution. Validates all statically defined conditions before delegating to execute(SlashCommandInteractionEvent).
      Specified by:
      handle in interface ISlashCommand
      Parameters:
      event - The SlashCommandInteractionEvent triggered by Discord.
      replyConfig - The configuration used for custom error/rejection messages.
    • execute

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