Package com.jagrosh.jdautilities.command
Class ContextMenu
java.lang.Object
com.jagrosh.jdautilities.command.Interaction
com.jagrosh.jdautilities.command.ContextMenu
- Direct Known Subclasses:
MessageContextMenu
,UserContextMenu
Middleware for child context menu types. Anything that extends this class will inherit the following options.
- Author:
- Olivia (Chew)
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
The name of the command.Localization of menu names.Fields inherited from class com.jagrosh.jdautilities.command.Interaction
botMissingPermMessage, botPermissions, cooldown, cooldownScope, guildOnly, nsfwOnly, ownerCommand, userMissingPermMessage, userPermissions
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionnet.dv8tion.jda.api.interactions.commands.build.CommandData
Builds CommandData for the ContextMenu upsert.getCooldownError
(net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent event, int remaining, CommandClient client) Gets an error message for this Context Menu under the providedGenericCommandInteractionEvent
.getCooldownKey
(net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent event) Gets the proper cooldown key for this Command under the providedGenericCommandInteractionEvent
.getName()
Gets theContextMenu.name
for the Context Menu.Gets the specified localizations of menu name.net.dv8tion.jda.api.interactions.commands.Command.Type
getType()
Gets the type of context menu.Methods inherited from class com.jagrosh.jdautilities.command.Interaction
getBotPermissions, getCooldown, getCooldownScope, getUserPermissions, isOwnerCommand
-
Field Details
-
name
The name of the command. This appears in the context menu. Can be 1-32 characters long. Spaces are allowed.- See Also:
-
CommandData.setName(String)
-
nameLocalization
Localization of menu names. Allows discord to change the language of the name of menu in the client.
-
-
Constructor Details
-
ContextMenu
public ContextMenu()
-
-
Method Details
-
getName
Gets theContextMenu.name
for the Context Menu.- Returns:
- The name for the Context Menu.
-
getNameLocalization
Gets the specified localizations of menu name.- Returns:
- Menu name localizations.
-
getType
public net.dv8tion.jda.api.interactions.commands.Command.Type getType()Gets the type of context menu.- Returns:
- the type
-
getCooldownKey
public String getCooldownKey(net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent event) Gets the proper cooldown key for this Command under the providedGenericCommandInteractionEvent
.- Parameters:
event
- The ContextMenuEvent to generate the cooldown for.- Returns:
- A String key to use when applying a cooldown.
-
getCooldownError
public String getCooldownError(net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent event, int remaining, CommandClient client) Gets an error message for this Context Menu under the providedGenericCommandInteractionEvent
.- Parameters:
event
- The event to generate the error message for.remaining
- The remaining number of seconds a context menu is on cooldown for.client
- the client- Returns:
- A String error message for this menu if
remaining > 0
, elsenull
.
-
buildCommandData
public net.dv8tion.jda.api.interactions.commands.build.CommandData buildCommandData()Builds CommandData for the ContextMenu upsert. This code is executed when we need to upsert the menu. Useful for manual upserting.- Returns:
- the built command data
-