Package com.jagrosh.jdautilities.command
Class UserContextMenu
java.lang.Object
com.jagrosh.jdautilities.command.Interaction
com.jagrosh.jdautilities.command.ContextMenu
com.jagrosh.jdautilities.command.UserContextMenu
User Context Menus In JDA-Chewtils
The internal inheritance for User Context Menus used in JDA-Chewtils is that of the object.
Classes created inheriting this class gain the unique traits of commands operated using the menu Extension.
Using several fields, a menu can define properties that make it unique and complex while maintaining
a low level of development.
All classes extending this class can define any number of these fields in a object constructor and then
create the menu action/response in the abstract execute(UserContextMenuEvent) body:
public class ExampleCmd extends UserContextMenu {
public ExampleCmd() {
this.name = "Example";
}
@Override
protected void execute(UserContextMenu event) {
event.reply("Hey look! This would be the bot's reply if this was a command!");
}
}
Execution is with the provision of a UserContextInteractionEvent-CommandClient wrapper called a
UserContextMenuEvent and is performed in two steps:
- Author:
- Olivia (Chew)
-
Field Summary
Fields inherited from class com.jagrosh.jdautilities.command.ContextMenu
name, nameLocalizationFields inherited from class com.jagrosh.jdautilities.command.Interaction
botMissingPermMessage, botPermissions, cooldown, cooldownScope, guildOnly, nsfwOnly, ownerCommand, userMissingPermMessage, userPermissions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.dv8tion.jda.api.interactions.commands.build.CommandDataBuilds CommandData for the ContextMenu upsert.protected abstract voidexecute(UserContextMenuEvent event) The main body method of aUserContextMenu.final voidrun(UserContextMenuEvent event) Runs checks for theUserContextMenuwith the givenMessageContextMenuEventthat called it.Methods inherited from class com.jagrosh.jdautilities.command.ContextMenu
getCooldownError, getCooldownKey, getName, getNameLocalization, getTypeMethods inherited from class com.jagrosh.jdautilities.command.Interaction
getBotPermissions, getCooldown, getCooldownScope, getUserPermissions, isOwnerCommand
-
Constructor Details
-
UserContextMenu
public UserContextMenu()
-
-
Method Details
-
run
Runs checks for theUserContextMenuwith the givenMessageContextMenuEventthat called it.
Will terminate, and possibly respond with a failure message, if any checks fail.- Parameters:
event- The UserContextMenuEvent that triggered this Context Menu
-
execute
The main body method of aUserContextMenu.
This is the "response" for a successfulrun(UserContextMenuEvent)- Parameters:
event- TheUserContextMenuEventthat triggered this menu.
-
buildCommandData
public net.dv8tion.jda.api.interactions.commands.build.CommandData buildCommandData()Description copied from class:ContextMenuBuilds CommandData for the ContextMenu upsert. This code is executed when we need to upsert the menu. Useful for manual upserting.- Overrides:
buildCommandDatain classContextMenu- Returns:
- the built command data
-