Class MessageContextMenuEvent
- All Implemented Interfaces:
net.dv8tion.jda.api.entities.ISnowflake
,net.dv8tion.jda.api.events.GenericEvent
,net.dv8tion.jda.api.interactions.callbacks.IDeferrableCallback
,net.dv8tion.jda.api.interactions.callbacks.IModalCallback
,net.dv8tion.jda.api.interactions.callbacks.IReplyCallback
,net.dv8tion.jda.api.interactions.commands.CommandInteraction
,net.dv8tion.jda.api.interactions.commands.CommandInteractionPayload
,net.dv8tion.jda.api.interactions.commands.context.ContextInteraction<net.dv8tion.jda.api.entities.Message>
,net.dv8tion.jda.api.interactions.commands.context.MessageContextInteraction
,net.dv8tion.jda.api.interactions.Interaction
Message Context Menus In JDA-Chewtils
The internal inheritance for Message 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 command 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 MessageContextMenu.execute(MessageContextMenuEvent)
body:
public class ExampleCmd extends MessageContextMenu {
public ExampleCmd() {
this.name = "Example";
}
@Override
protected void execute(MessageContextMenuEvent event) {
event.reply("Hey look! This would be the bot's reply if this was a command!");
}
}
Execution is with the provision of a MessageContextInteractionEvent-CommandClient wrapper called a
MessageContextMenu
and is performed in two steps:
- Author:
- Olivia (Chew)
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.dv8tion.jda.api.interactions.commands.context.ContextInteraction
net.dv8tion.jda.api.interactions.commands.context.ContextInteraction.ContextTarget
-
Field Summary
Fields inherited from class net.dv8tion.jda.api.events.Event
api, rawData, responseNumber
-
Constructor Summary
ConstructorDescriptionMessageContextMenuEvent
(net.dv8tion.jda.api.JDA api, long responseNumber, net.dv8tion.jda.api.interactions.commands.context.MessageContextInteraction interaction, CommandClient client) -
Method Summary
Modifier and TypeMethodDescriptionReturns theCommandClient
that initiated this event.boolean
isOwner()
Tests whether theUser
who triggered this event is an owner of the bot.void
Replies with aFile
with the provided name, or a default name if left null.void
Responds with a String message.void
respond
(net.dv8tion.jda.api.entities.MessageEmbed embed) Responds with aMessageEmbed
.void
respond
(net.dv8tion.jda.api.utils.messages.MessageCreateData message) Replies with aMessage
.Methods inherited from class net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent
getChannel, getInteraction
Methods inherited from class net.dv8tion.jda.api.events.interaction.command.GenericContextInteractionEvent
getTarget, getTargetType
Methods inherited from class net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent
deferReply, getCommandIdLong, getCommandType, getHook, getName, getOptions, getSubcommandGroup, getSubcommandName, isGuildCommand, replyModal
Methods inherited from class net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
getGuild, getGuildLocale, getIdLong, getMember, getToken, getTypeRaw, getUser, getUserLocale, isAcknowledged
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getRawData, getResponseNumber, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.dv8tion.jda.api.interactions.commands.CommandInteractionPayload
getCommandId, getCommandIdLong, getCommandString, getCommandType, getFullCommandName, getName, getOption, getOption, getOption, getOption, getOptions, getOptionsByName, getOptionsByType, getSubcommandGroup, getSubcommandName, isGlobalCommand, isGuildCommand
Methods inherited from interface net.dv8tion.jda.api.interactions.commands.context.ContextInteraction
getTarget
Methods inherited from interface net.dv8tion.jda.api.interactions.callbacks.IDeferrableCallback
getHook
Methods inherited from interface net.dv8tion.jda.api.interactions.callbacks.IModalCallback
replyModal
Methods inherited from interface net.dv8tion.jda.api.interactions.Interaction
getChannelType, getGuild, getGuildLocale, getJDA, getMember, getMessageChannel, getToken, getType, getTypeRaw, getUser, getUserLocale, isAcknowledged, isFromGuild
Methods inherited from interface net.dv8tion.jda.api.interactions.callbacks.IReplyCallback
deferReply, deferReply, reply, reply, replyComponents, replyComponents, replyEmbeds, replyEmbeds, replyFiles, replyFiles, replyFormat
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getIdLong, getTimeCreated
Methods inherited from interface net.dv8tion.jda.api.interactions.commands.context.MessageContextInteraction
getGuildChannel, getTargetType
-
Constructor Details
-
MessageContextMenuEvent
public MessageContextMenuEvent(@NotNull net.dv8tion.jda.api.JDA api, long responseNumber, @NotNull net.dv8tion.jda.api.interactions.commands.context.MessageContextInteraction interaction, CommandClient client)
-
-
Method Details
-
getClient
Returns theCommandClient
that initiated this event.- Returns:
- The initiating CommandClient
-
respond
Responds with a String message.The
ReplyCallbackAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.- Parameters:
message
- A String message to reply with
-
respond
public void respond(net.dv8tion.jda.api.entities.MessageEmbed embed) Responds with aMessageEmbed
.The
ReplyCallbackAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.- Parameters:
embed
- The MessageEmbed to reply with
-
respond
public void respond(net.dv8tion.jda.api.utils.messages.MessageCreateData message) Replies with aMessage
.The
ReplyCallbackAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.- Parameters:
message
- The Message to reply with
-
respond
Replies with aFile
with the provided name, or a default name if left null.The
ReplyCallbackAction
returned by sending the response as aMessage
automatically doesRestAction#queue()
.This method uses
IReplyCallback.replyFiles(net.dv8tion.jda.api.utils.FileUpload...)
to send the File. For more information on what a bot may send using this, you may find the info in that method.- Parameters:
file
- The File to reply withfilename
- The filename that Discord should display (null for default).description
- The description to set (null for no description).spoiler
- whether the file should be marked as spoiler.
-
isOwner
public boolean isOwner()Tests whether theUser
who triggered this event is an owner of the bot.- Returns:
true
if the User is the Owner, elsefalse
-