Class BaseMessageContextMenu
java.lang.Object
com.dianxin.tori.api.commands.messagecontext.BaseMessageContextMenu
- All Implemented Interfaces:
IMessageContextMenu
An abstract base class for statically configured Message Context Menus.
This class relies on constructor parameters or a builder to define its metadata
and execution constraints (such as required permissions or channel restrictions)
instead of class-level annotations, ensuring optimized performance.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBaseMessageContextMenu(String title, 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 BaseMessageContextMenu with explicit parameters.BaseMessageContextMenu(String title, net.dv8tion.jda.api.JDA jda, IBotMeta meta, LegacyCommandBuilder builder) Constructs a statically configured BaseMessageContextMenu using aLegacyCommandBuilder. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidexecute(net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event) The core execution logic of the message 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.getTitle()Retrieves the title of the context menu as shown in the Discord client.final voidhandle(net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event, CommandReplyConfig replyConfig) Handles the lifecycle and validation of the message context menu execution.
-
Field Details
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Details
-
BaseMessageContextMenu
public BaseMessageContextMenu(String title, 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 BaseMessageContextMenu with explicit parameters.- Parameters:
title- The name or title of the context menu displayed in Discord.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 (servers).ownerOnly- Whether the command is restricted strictly 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 invoking the command.selfPermissionsRequired- A list of permissions required by the bot itself.isDebug- Whether to log debug information upon execution.
-
BaseMessageContextMenu
public BaseMessageContextMenu(String title, net.dv8tion.jda.api.JDA jda, IBotMeta meta, LegacyCommandBuilder builder) Constructs a statically configured BaseMessageContextMenu using aLegacyCommandBuilder.- Parameters:
title- The name or title of the context menu displayed in Discord.jda- TheJDAinstance running this command.meta- TheIBotMetacontaining the bot's metadata.builder- The configuredLegacyCommandBuildercontaining execution constraints.
-
-
Method Details
-
getJda
protected net.dv8tion.jda.api.JDA getJda()Retrieves the JDA instance associated with this command.- Returns:
- The
JDAinstance.
-
getTitle
Retrieves the title of the context menu as shown in the Discord client.- Returns:
- The title string.
-
getLogger
protected org.slf4j.Logger getLogger()Retrieves the logger instance for the current command.- Returns:
- The
Loggerinstance.
-
handle
public final void handle(net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event, CommandReplyConfig replyConfig) Handles the lifecycle and validation of the message context menu execution. Validates all statically defined conditions before delegating toexecute(MessageContextInteractionEvent).- Specified by:
handlein interfaceIMessageContextMenu- Parameters:
event- TheMessageContextInteractionEventtriggered by Discord.replyConfig- The configuration used for custom error or rejection messages.
-
execute
protected abstract void execute(net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent event) The core execution logic of the message context menu command. Developers must implement this method to define what the command actually does after passing all checks.- Parameters:
event- The validMessageContextInteractionEventpassed through all pre-execution checks.
-