Class ApplicationCommandOption

java.lang.Object
discord4j.core.object.command.ApplicationCommandOption
All Implemented Interfaces:
DiscordObject

@Experimental public class ApplicationCommandOption extends Object implements DiscordObject
A Discord application command option.
See Also:
  • Field Details

    • MAX_NAME_LENGTH

      public static final int MAX_NAME_LENGTH
      The maximum amount of characters that can be in an application command option name.
      See Also:
    • MAX_DESCRIPTION_LENGTH

      public static final int MAX_DESCRIPTION_LENGTH
      The maximum amount of characters that can be in an application command option description.
      See Also:
  • Constructor Details

    • ApplicationCommandOption

      public ApplicationCommandOption(GatewayDiscordClient gateway, discord4j.discordjson.json.ApplicationCommandOptionData data)
      Constructs an ApplicationCommandOption with an associated GatewayDiscordClient and Discord data.
      Parameters:
      gateway - The GatewayDiscordClient associated to this object, must be non-null.
      data - The raw data as represented by Discord, must be non-null.
  • Method Details

    • getType

      Gets the type of the option.
      Returns:
      The type of the option.
    • getName

      public String getName()
      Gets the name of the option.
      Returns:
      The name of the option.
    • getLocalizedNames

      public Map<Locale,String> getLocalizedNames()
      Gets the Locale and name of the option.
      Returns:
      The locales and names of the option.
    • getDescription

      public String getDescription()
      Gets the description of the option.
      Returns:
      The description of the option.
    • getLocalizedDescriptions

      public Map<Locale,String> getLocalizedDescriptions()
      Gets the Locale and description of the option.
      Returns:
      The locales and descriptions of the option.
    • isRequired

      public boolean isRequired()
      Gets whether this option is required.
      Returns:
      Whether this option is required.
    • getChoices

      public List<ApplicationCommandOptionChoice> getChoices()
      Gets the choices for string and int types for the user to pick from.
      Returns:
      The choices for string and int types for the user to pick from.
    • getChoice

      Gets the choice corresponding to the provided name, if present.
      Parameters:
      name - The name of the choice.
      Returns:
      The choice corresponding to the provided name, if present.
    • getOptions

      public List<ApplicationCommandOption> getOptions()
      Gets the options, if the option is a subcommand or subcommand group type.
      Returns:
      The options, if the option is a subcommand or subcommand group type.
    • getOption

      public Optional<ApplicationCommandOption> getOption(String name)
      Gets the option corresponding to the provided name, if present and if this option is a subcommand or subcommand group type.
      Parameters:
      name - The name of the option.
      Returns:
      The option corresponding to the provided name, if present and if this option is a subcommand or subcommand group type.
    • getAllowedChannelTypes

      public List<Channel.Type> getAllowedChannelTypes()
      Returns a list of acceptable channel types the user may pick

      Only applies to CHANNEL type options, if empty, no restriction on channel types is placed.
      Returns:
      A list of channel types a user may pick. Empty list means no restriction is applied.
    • hasAutocompleteEnabled

      public boolean hasAutocompleteEnabled()
      Whether this option supports auto-complete or not. Default is false.

      Autocomplete cannot be enabled on options that have choices.
      Returns:
      Whether this option supports auto-complete or not.
    • getMinimumValue

      public Optional<Double> getMinimumValue()
      Returns the minimum value a user is allowed to input, represented as a Double.

      This is only applicable to ApplicationCommandOption.Type.INTEGER and ApplicationCommandOption.Type.NUMBER types.
      Returns:
      The minimum value a user is allowed to input if present, otherwise Optional.empty().
    • getMaximumValue

      public Optional<Double> getMaximumValue()
      Returns the maximum value a user is allowed to input, represented as a Double.

      This is only applicable to ApplicationCommandOption.Type.INTEGER and ApplicationCommandOption.Type.NUMBER types.
      Returns:
      The maximum value a user is allowed to input if present, otherwise Optional.empty().
    • getMinimumLength

      public Optional<Integer> getMinimumLength()
      Returns the minimum length a user is allowed to input, represented as a Integer.

      This is only applicable to ApplicationCommandOption.Type.STRING type.
      Returns:
      The minimum length a user is allowed to input if present, otherwise Optional.empty().
    • getMaximumLength

      public Optional<Integer> getMaximumLength()
      Returns the maximum length a user is allowed to input, represented as a Integer.

      This is only applicable to ApplicationCommandOption.Type.STRING type.
      Returns:
      The maximum length a user is allowed to input if present, otherwise Optional.empty().
    • getClient

      public GatewayDiscordClient getClient()
      Description copied from interface: DiscordObject
      Returns the GatewayDiscordClient that created this object. Methods in it are exclusively based on the entity cache or Store in use. Refer to calling getClient().rest() to access a DiscordClient that is capable of requesting entities directly from the REST API.
      Specified by:
      getClient in interface DiscordObject
      Returns:
      The GatewayDiscordClient associated to this object.