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.PermissionSet
getDefaultMemberPermissions()
Gets the default permissions assigned to this Application Command for member.String
getDescription()
Gets description of the command.Optional<Snowflake>
getGuildId()
Gets the id of the guild if the command is guild scoped.Snowflake
getId()
Gets unique id of the command.Map<Locale,String>
getLocalizedDescriptions()
Gets the Locale and description of the command.Map<Locale,String>
getLocalizedNames()
Gets the Locale and name 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.Snowflake
getVersion()
Gets the version of the command.boolean
isAvailableInDM()
Gets if the command is available in DM, this only for global commands.
-
-
-
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.
-
getVersion
public Snowflake getVersion()
Gets the version of the command.- Returns:
- The version of the command
-
getGuildId
public Optional<Snowflake> getGuildId()
Gets the id of the guild if the command is guild scoped.- Returns:
- The id of the guild
-
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.
-
getLocalizedNames
public Map<Locale,String> getLocalizedNames()
Gets the Locale and name of the command.- Returns:
- The locales and names of the command.
-
getDescription
public String getDescription()
Gets description of the command.- Returns:
- The description of the command.
-
getLocalizedDescriptions
public Map<Locale,String> getLocalizedDescriptions()
Gets the Locale and description of the command.- Returns:
- The locales and descriptions of the command.
-
getDefaultMemberPermissions
public PermissionSet getDefaultMemberPermissions()
Gets the default permissions assigned to this Application Command for member.- Returns:
- The permissions assigned to this Application 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.
-
isAvailableInDM
public boolean isAvailableInDM()
Gets if the command is available in DM, this only for global commands.- Returns:
true
if the command is available in DM,false
otherwise.
-
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.
-
-