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, nameLocalization
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.protected abstract void
execute
(UserContextMenuEvent event) The main body method of aUserContextMenu
.final void
run
(UserContextMenuEvent event) Runs checks for theUserContextMenu
with the givenMessageContextMenuEvent
that called it.Methods inherited from class com.jagrosh.jdautilities.command.ContextMenu
getCooldownError, getCooldownKey, getName, getNameLocalization, getType
Methods inherited from class com.jagrosh.jdautilities.command.Interaction
getBotPermissions, getCooldown, getCooldownScope, getUserPermissions, isOwnerCommand
-
Constructor Details
-
UserContextMenu
public UserContextMenu()
-
-
Method Details
-
run
Runs checks for theUserContextMenu
with the givenMessageContextMenuEvent
that 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
- TheUserContextMenuEvent
that triggered this menu.
-
buildCommandData
public net.dv8tion.jda.api.interactions.commands.build.CommandData buildCommandData()Description copied from class:ContextMenu
Builds CommandData for the ContextMenu upsert. This code is executed when we need to upsert the menu. Useful for manual upserting.- Overrides:
buildCommandData
in classContextMenu
- Returns:
- the built command data
-