Class ModernBaseCommand
java.lang.Object
com.dianxin.tori.api.commands.slash.ModernBaseCommand
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionModernBaseCommand(net.dv8tion.jda.api.JDA jda, IBotMeta meta) Constructs a new ModernBaseCommand. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidexecute(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event) The core execution logic of the command.protected net.dv8tion.jda.api.JDAgetJda()protected org.slf4j.Loggerfinal voidhandle(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event, CommandReplyConfig replyConfig) Handles the lifecycle and validation of the command execution.
-
Constructor Details
-
ModernBaseCommand
Constructs a new ModernBaseCommand.- Parameters:
jda- TheJDAinstance running this command.meta- TheIBotMetacontaining 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 toexecute(SlashCommandInteractionEvent).- Specified by:
handlein interfaceISlashCommand- Parameters:
event- TheSlashCommandInteractionEventtriggered 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 validSlashCommandInteractionEventpassed through all pre-checks.
-