Class ModernBaseUserContextMenu
java.lang.Object
com.dianxin.tori.api.commands.usercontext.ModernBaseUserContextMenu
- All Implemented Interfaces:
IUserContextMenu
An abstract base class for modern User Context Menus.
Subclasses extending this class must be annotated with ContextMenu
to provide the necessary metadata (like the interaction name) to the CommandRegistrar.
-
Constructor Summary
ConstructorsConstructorDescriptionModernBaseUserContextMenu(net.dv8tion.jda.api.JDA jda, IBotMeta meta) Constructs a new ModernBaseUserContextMenu. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidexecute(net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent event) The core execution logic of the user context menu command.protected net.dv8tion.jda.api.JDAgetJda()Retrieves the JDA instance associated with this command.protected org.slf4j.LoggerRetrieves the logger instance for the current command.final voidhandle(net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent event, CommandReplyConfig replyConfig) Handles the lifecycle and validation of the user context menu execution.
-
Constructor Details
-
ModernBaseUserContextMenu
Constructs a new ModernBaseUserContextMenu.- Parameters:
jda- TheJDAinstance running this command.meta- TheIBotMetacontaining the bot's metadata.
-
-
Method Details
-
getLogger
protected org.slf4j.Logger getLogger()Retrieves the logger instance for the current command. * @return TheLoggerinstance. -
getJda
protected net.dv8tion.jda.api.JDA getJda()Retrieves the JDA instance associated with this command. * @return TheJDAinstance. -
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. Parses the command's class annotations to enforce restrictions before delegating toexecute(UserContextInteractionEvent).- Specified by:
handlein interfaceIUserContextMenu- Parameters:
event- TheUserContextInteractionEventtriggered 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 validUserContextInteractionEventpassed through all pre-execution checks.
-