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
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_DESCRIPTION_LENGTH
The maximum amount of characters that can be in an application command option description.static int
MAX_NAME_LENGTH
The 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 anApplicationCommandOption
with an associatedGatewayDiscordClient
and Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<ApplicationCommandOptionChoice>
getChoice(String name)
Gets the choice corresponding to the provided name, if present.List<ApplicationCommandOptionChoice>
getChoices()
Gets the choices forstring
andint
types for the user to pick from.GatewayDiscordClient
getClient()
Returns theGatewayDiscordClient
that created this object.String
getDescription()
Gets the description of the option.String
getName()
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.ApplicationCommandOptionType
getType()
Gets the type of the option.boolean
isRequired()
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 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 Detail
-
getType
public ApplicationCommandOptionType 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 forstring
andint
types for the user to pick from.- Returns:
- The choices for
string
andint
types 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.
-
getClient
public GatewayDiscordClient 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.
-
-