Package discord4j.core.object.command
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:
- Application Command Option Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classApplicationCommandOption.Type
-
Field Summary
Fields Modifier and Type Field Description static intMAX_DESCRIPTION_LENGTHThe maximum amount of characters that can be in an application command option description.static intMAX_NAME_LENGTHThe maximum amount of characters that can be in an application command option name.
-
Constructor Summary
Constructors Constructor Description ApplicationCommandOption(GatewayDiscordClient gateway, discord4j.discordjson.json.ApplicationCommandOptionData data)Constructs anApplicationCommandOptionwith an associatedGatewayDiscordClientand Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Channel.Type>getAllowedChannelTypes()Returns a list of acceptable channel types the user may pickOptional<ApplicationCommandOptionChoice>getChoice(String name)Gets the choice corresponding to the provided name, if present.List<ApplicationCommandOptionChoice>getChoices()Gets the choices forstringandinttypes for the user to pick from.GatewayDiscordClientgetClient()Returns theGatewayDiscordClientthat created this object.StringgetDescription()Gets the description of the option.Optional<Double>getMaximumValue()Returns the maximum value a user is allowed to input, represented as aDouble.Optional<Double>getMinimumValue()Returns the minimum value a user is allowed to input, represented as aDouble.StringgetName()Gets the name of the option.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.List<ApplicationCommandOption>getOptions()Gets the options, if the option is a subcommand or subcommand group type.ApplicationCommandOption.TypegetType()Gets the type of the option.booleanhasAutocompleteEnabled()Whether this option supports auto-complete or not.booleanisRequired()Gets whether this option is required.
-
-
-
Field Detail
-
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:
- Constant Field Values
-
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:
- Constant Field Values
-
-
Constructor Detail
-
ApplicationCommandOption
public ApplicationCommandOption(GatewayDiscordClient gateway, discord4j.discordjson.json.ApplicationCommandOptionData data)
Constructs anApplicationCommandOptionwith an associatedGatewayDiscordClientand Discord data.- Parameters:
gateway- TheGatewayDiscordClientassociated to this object, must be non-null.data- The raw data as represented by Discord, must be non-null.
-
-
Method Detail
-
getType
public ApplicationCommandOption.Type 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.
-
getDescription
public String getDescription()
Gets the description of the option.- Returns:
- The description 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 forstringandinttypes for the user to pick from.- Returns:
- The choices for
stringandinttypes for the user to pick from.
-
getChoice
public Optional<ApplicationCommandOptionChoice> getChoice(String name)
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 aDouble. This is only applicable toApplicationCommandOption.Type.INTEGERandApplicationCommandOption.Type.NUMBERtypes.- 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 aDouble. This is only applicable toApplicationCommandOption.Type.INTEGERandApplicationCommandOption.Type.NUMBERtypes.- Returns:
- The maximum value a user is allowed to input if present, otherwise
Optional.empty().
-
getClient
public GatewayDiscordClient getClient()
Description copied from interface:DiscordObjectReturns theGatewayDiscordClientthat created this object. Methods in it are exclusively based on the entity cache orStorein use. Refer to callinggetClient().rest()to access aDiscordClientthat is capable of requesting entities directly from the REST API.- Specified by:
getClientin interfaceDiscordObject- Returns:
- The
GatewayDiscordClientassociated to this object.
-
-