Package discord4j.core.object.command
Class ApplicationCommand
- java.lang.Object
-
- discord4j.core.object.command.ApplicationCommand
-
- All Implemented Interfaces:
DiscordObject
@Experimental public class ApplicationCommand extends Object implements DiscordObject
A Discord application command.- See Also:
- Application Command Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ApplicationCommand.Type
-
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 description.static int
MAX_NAME_LENGTH
The maximum amount of characters that can be in an application command name.
-
Constructor Summary
Constructors Constructor Description ApplicationCommand(GatewayDiscordClient gateway, discord4j.discordjson.json.ApplicationCommandData data)
Constructs anApplicationCommand
with an associatedGatewayDiscordClient
and Discord data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Snowflake
getApplicationId()
Gets the unique id of the parent application.GatewayDiscordClient
getClient()
Returns theGatewayDiscordClient
that created this object.String
getDescription()
Gets description of the command.Snowflake
getId()
Gets unique id of the command.String
getName()
Gets the name of the command.Optional<ApplicationCommandOption>
getOption(String name)
Gets the option corresponding to the provided name, if present.List<ApplicationCommandOption>
getOptions()
Gets the options of the command.ApplicationCommand.Type
getType()
Gets the type of the command.
-
-
-
Field Detail
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTH
The maximum amount of characters that can be in an application command 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 description.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ApplicationCommand
public ApplicationCommand(GatewayDiscordClient gateway, discord4j.discordjson.json.ApplicationCommandData data)
Constructs anApplicationCommand
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
-
getId
public Snowflake getId()
Gets unique id of the command.- Returns:
- The unique id of the command.
-
getType
public ApplicationCommand.Type getType()
Gets the type of the command.- Returns:
- The type of the command.
-
getApplicationId
public Snowflake getApplicationId()
Gets the unique id of the parent application.- Returns:
- The unique id of the parent application.
-
getName
public String getName()
Gets the name of the command.- Returns:
- The name of the command.
-
getDescription
public String getDescription()
Gets description of the command.- Returns:
- The description of the command.
-
getOptions
public List<ApplicationCommandOption> getOptions()
Gets the options of the command.- Returns:
- The options of the command.
-
getOption
public Optional<ApplicationCommandOption> getOption(String name)
Gets the option corresponding to the provided name, if present.- Parameters:
name
- The name of the option.- Returns:
- The option corresponding to the provided name, if present.
-
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.
-
-