Package discord4j.core.object.command
Class ApplicationCommandOption
java.lang.Object
discord4j.core.object.command.ApplicationCommandOption
- All Implemented Interfaces:
DiscordObject
A Discord application command option.
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum amount of characters that can be in an application command option description.static final int
The maximum amount of characters that can be in an application command option name. -
Constructor Summary
ConstructorDescriptionApplicationCommandOption
(GatewayDiscordClient gateway, discord4j.discordjson.json.ApplicationCommandOptionData data) Constructs anApplicationCommandOption
with an associatedGatewayDiscordClient
and Discord data. -
Method Summary
Modifier and TypeMethodDescriptionReturns a list of acceptable channel types the user may pickGets the choice corresponding to the provided name, if present.Gets the choices forstring
andint
types for the user to pick from.Returns theGatewayDiscordClient
that created this object.Gets the description of the option.Gets the Locale and description of the option.Gets the Locale and name of the option.Returns the maximum length a user is allowed to input, represented as aInteger
.Returns the maximum value a user is allowed to input, represented as aDouble
.Returns the minimum length a user is allowed to input, represented as aInteger
.Returns the minimum value a user is allowed to input, represented as aDouble
.getName()
Gets the name of the option.Gets the option corresponding to the provided name, if present and if this option is a subcommand or subcommand group type.Gets the options, if the option is a subcommand or subcommand group type.getType()
Gets the type of the option.boolean
Whether this option supports auto-complete or not.boolean
Gets whether this option is required.
-
Field Details
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHThe maximum amount of characters that can be in an application command option name.- See Also:
-
MAX_DESCRIPTION_LENGTH
public static final int MAX_DESCRIPTION_LENGTHThe 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 anApplicationCommandOption
with an associatedGatewayDiscordClient
and Discord data.- Parameters:
gateway
- TheGatewayDiscordClient
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
Gets the name of the option.- Returns:
- The name of the option.
-
getLocalizedNames
Gets the Locale and name of the option.- Returns:
- The locales and names of the option.
-
getDescription
Gets the description of the option.- Returns:
- The description of the option.
-
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
Gets the choices forstring
andint
types for the user to pick from.- Returns:
- The choices for
string
andint
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
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
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
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
Returns the minimum value a user is allowed to input, represented as aDouble
. This is only applicable toApplicationCommandOption.Type.INTEGER
andApplicationCommandOption.Type.NUMBER
types.- Returns:
- The minimum value a user is allowed to input if present, otherwise
Optional.empty()
.
-
getMaximumValue
Returns the maximum value a user is allowed to input, represented as aDouble
. This is only applicable toApplicationCommandOption.Type.INTEGER
andApplicationCommandOption.Type.NUMBER
types.- Returns:
- The maximum value a user is allowed to input if present, otherwise
Optional.empty()
.
-
getMinimumLength
Returns the minimum length a user is allowed to input, represented as aInteger
. This is only applicable toApplicationCommandOption.Type.STRING
type.- Returns:
- The minimum length a user is allowed to input if present, otherwise
Optional.empty()
.
-
getMaximumLength
Returns the maximum length a user is allowed to input, represented as aInteger
. This is only applicable toApplicationCommandOption.Type.STRING
type.- Returns:
- The maximum length a user is allowed to input if present, otherwise
Optional.empty()
.
-
getClient
Description copied from interface:DiscordObject
Returns theGatewayDiscordClient
that created this object. Methods in it are exclusively based on the entity cache orStore
in use. Refer to callinggetClient().rest()
to access aDiscordClient
that is capable of requesting entities directly from the REST API.- Specified by:
getClient
in interfaceDiscordObject
- Returns:
- The
GatewayDiscordClient
associated to this object.
-