Class MessageContextMenuEvent

java.lang.Object
net.dv8tion.jda.api.events.Event
net.dv8tion.jda.api.events.interaction.GenericInteractionCreateEvent
net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent
net.dv8tion.jda.api.events.interaction.command.GenericContextInteractionEvent<net.dv8tion.jda.api.entities.Message>
net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent
com.jagrosh.jdautilities.command.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

public class MessageContextMenuEvent extends net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent

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:
  • run - The menu runs through a series of conditionals, automatically terminating the command instance if one is not met, and possibly providing an error response.
  • execute - The menu, now being cleared to run, executes and performs whatever lies in the abstract body method.
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

    Constructors
    Constructor
    Description
    MessageContextMenuEvent(net.dv8tion.jda.api.JDA api, long responseNumber, net.dv8tion.jda.api.interactions.commands.context.MessageContextInteraction interaction, CommandClient client)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the CommandClient that initiated this event.
    boolean
    Tests whether the User who triggered this event is an owner of the bot.
    void
    respond(File file, String filename, String description, boolean spoiler)
    Replies with a File with the provided name, or a default name if left null.
    void
    respond(String message)
    Responds with a String message.
    void
    respond(net.dv8tion.jda.api.entities.MessageEmbed embed)
    Responds with a MessageEmbed.
    void
    respond(net.dv8tion.jda.api.utils.messages.MessageCreateData message)
    Replies with a Message.

    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

      public CommandClient getClient()
      Returns the CommandClient that initiated this event.
      Returns:
      The initiating CommandClient
    • respond

      public void respond(String message)
      Responds with a String message.

      The ReplyCallbackAction returned by sending the response as a Message automatically does RestAction#queue().

      Parameters:
      message - A String message to reply with
    • respond

      public void respond(net.dv8tion.jda.api.entities.MessageEmbed embed)
      Responds with a MessageEmbed.

      The ReplyCallbackAction returned by sending the response as a Message automatically does RestAction#queue().

      Parameters:
      embed - The MessageEmbed to reply with
    • respond

      public void respond(net.dv8tion.jda.api.utils.messages.MessageCreateData message)
      Replies with a Message.

      The ReplyCallbackAction returned by sending the response as a Message automatically does RestAction#queue().

      Parameters:
      message - The Message to reply with
    • respond

      public void respond(File file, String filename, String description, boolean spoiler)
      Replies with a File with the provided name, or a default name if left null.

      The ReplyCallbackAction returned by sending the response as a Message automatically does RestAction#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 with
      filename - 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 the User who triggered this event is an owner of the bot.
      Returns:
      true if the User is the Owner, else false