Class ModernBaseCommand

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

public abstract class ModernBaseCommand extends Object implements ISlashCommand
The modern, annotation-driven base class for all slash commands. Developers can use annotations like @GuildOnly or @RequirePermissions on subclasses to dynamically enforce execution rules.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ModernBaseCommand(net.dv8tion.jda.api.JDA jda, IBotMeta meta)
    Constructs a new ModernBaseCommand.
  • 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

    • ModernBaseCommand

      public ModernBaseCommand(net.dv8tion.jda.api.JDA jda, IBotMeta meta)
      Constructs a new ModernBaseCommand.
      Parameters:
      jda - The JDA instance running this command.
      meta - The IBotMeta containing the bot's metadata.
  • 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. Parses the command's class annotations to enforce restrictions 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.