Class BaseCommand
java.lang.Object
com.dianxin.tori.api.commands.slash.BaseCommand
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionBaseCommand(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 theLegacyCommandBuilder. -
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
-
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- TheJDAinstance running this command.meta- TheIBotMetacontaining 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
Constructs a BaseCommand using theLegacyCommandBuilder.- Parameters:
jda- TheJDAinstance running this command.meta- TheIBotMetacontaining the bot's metadata.builder- The configuredLegacyCommandBuilder.
-
-
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 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.
-