Class ContextMenu

java.lang.Object
com.jagrosh.jdautilities.command.Interaction
com.jagrosh.jdautilities.command.ContextMenu
Direct Known Subclasses:
MessageContextMenu, UserContextMenu

public abstract class ContextMenu extends Interaction
Middleware for child context menu types. Anything that extends this class will inherit the following options.
Author:
Olivia (Chew)
  • Field Details

    • name

      protected String 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

      protected Map<net.dv8tion.jda.api.interactions.DiscordLocale,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

      public String getName()
      Gets the ContextMenu.name for the Context Menu.
      Returns:
      The name for the Context Menu.
    • getNameLocalization

      public Map<net.dv8tion.jda.api.interactions.DiscordLocale,String> 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 provided GenericCommandInteractionEvent.
      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 provided GenericCommandInteractionEvent.
      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, else null.
    • 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