Application Commands
Application commands are commands that an application can register to Discord. They provide users a first-class way of interacting directly with your application that feels deeply integrated into Discord.
Application Command Naming
CHAT_INPUT and PRIMARY_ENTRY_POINT command names and command option names must match the regex ^[-_'\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$ with the unicode flag set. If there is a lowercase variant of any letters used, you must use those.
Characters with no lowercase variants and uncased letters are still allowed. USER and MESSAGE commands may be mixed case and can include spaces.
Application Command Object
Application Command Structure
| Field | Type | Description | Valid Types |
|---|---|---|---|
| id? 1 | snowflake | The ID of the command | All |
| type? | integer | The type of command (default CHAT_INPUT) | All |
| application_id 2 | snowflake | The ID of the application that the command belongs to | All |
| guild_id? 2 | snowflake | The ID of the guild the command is for | All |
| name | string | The name of the command (1-32 characters) | All |
| name_localizations? | ?map[string, string] | The localized name for each locale (values follow same restrictions as name) | All |
| name_localized? 2 | ?string | The localized name of the command | All |
| description | string | The description of the command (1-100 characters) | All |
| description_localizations? | ?map[string, string] | The localized description for each locale (values follow same restrictions as description) | All |
| description_localized? 2 | ?string | The localized description of the command | All |
| options? | array[application command option object] | The options for the command (max 25) | CHAT_INPUT |
| default_member_permissions | ?string | The default required permissions to call the command | All |
| dm_permission? 3 (deprecated) | boolean | Whether the command is available in DMs with the application (default true) | All |
| permissions? 4 | application command index permissions object | The command's permissions for the user in the guild | All |
| nsfw? | boolean | Whether the command is age-restricted (default false) | All |
| integration_types? 3 | array[integer] | The installation contexts where the command is available (defaults to application's configured contexts) | All |
| global_popularity_rank? 2 3 4 | integer | The popularity rank of the application command | All |
| contexts? 3 | ?array[integer] | The interaction context where the command can be used | All |
| version 2 | snowflake | An autoincrementing version identifier updated during substantial record changes | All |
| handler? 3 | integer | How the command should be handled when called | PRIMARY_ENTRY_POINT |
1 This field is always present when received.
2 This field is received only and cannot be set.
3 Only applicable for globally-scoped commands.
4 Only available within application command index objects.
Application Command Type
| Value | Name | Description |
|---|---|---|
| 1 | CHAT_INPUT | Slash commands; a text-based command that shows up when a user types / |
| 2 | USER | An UI-based command that shows up when you right click or tap on an user |
| 3 | MESSAGE | An UI-based command that shows up when you right click or tap on a message |
| 4 | PRIMARY_ENTRY_POINT | An UI-based command that represents the primary way to invoke an app's activity |
Application Command Option Structure
| Field | Type | Description |
|---|---|---|
| type | integer | The type of the option |
| name | string | The name of the option (1-100 characters) |
| name_localizations? | ?map[string, string] | The localized name for each locale (values follow same restrictions as name) |
| name_localized? 1 | ?string | The localized name of the option (1-100 characters) |
| description | string | The description of the option (1-100 characters) |
| description_localizations? | ?map[string, string] | The localized description for each locale (values follow same restrictions as description) |
| description_localized? 1 | ?string | The localized description of the option (1-100 characters) |
| required? | boolean | Whether the option is required (default false, only applicable when type is not SUB_COMMAND or SUB_COMMAND_GROUP) |
| choices? | array[application command option choice object] | The choices for the user to pick from (max 25, only applicable for STRING, INTEGER, and NUMBER options) |
| options? | array[application command option object] | The nested options (only applicable if the option is a subcommand or subcommand group) |
| channel_types? | array[integer] | The allowed channel types (only applicable for CHANNEL options) |
| min_value? | float | integer | The minimum value permitted (only applicable for INTEGER and NUMBER options) |
| max_value? | float | integer | The maximum value permitted (only applicable for INTEGER and NUMBER options) |
| min_length? | integer | The minimum length (0-6000, only applicable for STRING options) |
| max_length? | integer | The maximum length (0-6000, only applicable for STRING options) |
| autocomplete? | boolean | Whether the option can be autocompleted (only applicable for STRING, INTEGER, and NUMBER options) |
1 This field is received only and cannot be set.
Application Command Option Type
| Value | Name | Description |
|---|---|---|
| 1 | SUB_COMMAND | A subcommand |
| 2 | SUB_COMMAND_GROUP | A group of subcommands |
| 3 | STRING | A string |
| 4 | INTEGER | An integer between -253 and 253 |
| 5 | BOOLEAN | A boolean |
| 6 | USER | An user |
| 7 | CHANNEL | A channel (includes all channel types by default) |
| 8 | ROLE | A role |
| 9 | MENTIONABLE | A mentionable entity (currently only users and roles) |
| 10 | NUMBER | A float/integer between -253 and 253 |
| 11 | ATTACHMENT | An attachment |
Application Command Option Choice Structure
If you specify choices for an option, they are the only valid values for an user to pick.
| Field | Type | Description |
|---|---|---|
| name | string | The name of the choice (1-100 characters) |
| name_localizations? | ?map[string, string] | The localized name for each locale (values follow same restrictions as name) |
| name_localized? 1 | ?string | The localized name of the choice (1-100 characters) |
| value | float | integer | string | The value of the choice (max 100 characters if string) |
1 This field is received only and cannot be set.
Application Command Handler Type
| Value | Name | Description |
|---|---|---|
| 1 | APP_HANDLER | The application handles the interaction using an interaction token |
| 2 | DISCORD_LAUNCH_ACTIVITY | Discord handles the interaction by launching an embedded activity and sending a follow-up message without coordinating with the app |
| 3 | APP_HANDLER_LAUNCH_ACTIVITY | The application handles the interaction using an interaction token and can only use LAUNCH_ACTIVITY for responding |
Application Command Index Object
Multiple different resources have application command indexes, including guilds, users, and applications themselves.
Application Command Index Structure
| Field | Type | Description |
|---|---|---|
| applications | array[command index application object] | The applications relevant to the requested resource |
| application_commands | array[application command object] | The application commands |
| version | snowflake | A snowflake representing when commands were last updated |
Application Command Index Permissions Structure
| Field | Type | Description |
|---|---|---|
| user? | boolean | Whether the user can use application commands unless overridden by command permissions |
| roles? | map[snowflake, boolean] | Whether specific roles can use application commands unless overridden by command permissions |
| channels? | map[snowflake, boolean] | Whether specific channels can use application commands unless overridden by command permissions |
Command Index Application Structure
| Field | Type | Description |
|---|---|---|
| id | snowflake | The ID of the application |
| name | string | The name of the application |
| description | string | The description of the application |
| icon | ?string | The application's icon hash |
| permissions? | application command index permissions object | The application-wide command permissions for the user |
| bot? 1 | partial user object | The bot attached to this application |
| bot_id? | snowflake | The ID of the bot user attached to this application |
| flags | string | The application's flags |
| embedded_activity_config? 2 | partial embedded activity config object | The embedded activity configuration for the application |
1 Only included when fetched from the Get Application Command Index endpoint.
2 Embedded activity config objects will only contain the supported_platforms field.
Example Command Index Application
{"id": "891436233903964161","name": "Lightbulb","description": "💡 Let there be light","icon": "546242649e3b09a97af7e8f29983837b","permissions": {"roles": {"1029330445336313927": false},"channels": {"1029316811088478299": false}},"bot_id": "891436233903964161","flags": "0","embedded_activity_config": {"supported_platforms": ["web"]}}
Authorizing Your Application
Application commands do not depend on a bot user in the guild; they use the interactions model. To create commands in a guild, your application must be authorized with the applications.commands scope.
When requesting this scope, Discord "shortcuts" the OAuth2 flow similar to adding a bot. You don't need to complete the flow, exchange for a token, or any of that.
If your application does not require a bot user within the guild for its commands to work, you no longer need to add for the bot scope or specific permissions.
Registering a Command
Commands can be scoped either globally or to a specific guild. Global commands are available for every guild that adds your app. An individual app's global commands are also available in DMs if that app has a bot that shares a mutual guild with the user.
Guild commands are specific to the guild you specify when making them. Guild commands are not available in DMs. Command names are unique per application, per type, within each scope (global and guild). That means:
- Your app cannot have two global
CHAT_INPUTcommands with the same name - Your app cannot have two guild
CHAT_INPUTcommands within the same name on the same guild - Your app cannot have two global
USERcommands with the same name - Your app can have a global and guild
CHAT_INPUTcommand with the same name - Your app can have a global
CHAT_INPUTandUSERcommand with the same name - Multiple apps can have commands with the same names
This list is non-exhaustive. In general, remember that command names must be unique per application, per type, and within each scope (global and guild).
An app can have the following number of commands:
- 100 global
CHAT_INPUTcommands - 15 global
USERcommands - 15 global
MESSAGEcommands - 1 global
PRIMARY_ENTRY_POINTcommand
For all command types except PRIMARY_ENTRY_POINT, you can have the same amount of guild-specific commands per guild.
Making a Global Command
Simple example of making a global command
Making a Global Command
Simple example of making a global command
Global commands are available on all your app's guilds.
Global commands have inherent read-repair functionality. That means that if you make an update to a global command, and an user tries to use that command before it has updated for them, Discord will do an internal version check and reject the command, and trigger a reload for that command.
To make a global command, make an HTTP POST call like this:
Making a Guild Command
Simple example of making a guild command
Making a Guild Command
Simple example of making a guild command
Guild commands are available only within the guild specified on creation.
To make a guild command, make a similar HTTP POST call, but scope it to a specific guild_id:
Updating and Deleting a Command
Commands can be deleted and updated by making DELETE and PATCH calls to the command endpoint. Those endpoints are
/applications/{application.id}/commands/{command.id}for global commands, or/applications/{application.id}/guilds/{guild.id}/commands/{command.id}for guild commands
Because commands have unique names within a type and scope, Discord treats POST requests for new commands as upserts. That means making a new command with an already-used name for your application will update the existing command.
Full documentation of endpoints can be found here.
Contexts
Commands have two sets of contexts on the application command object that let you to configure when and where it can be used:
integration_typesdefines the installation contexts that a command supportscontextsdefines the interaction contexts where a command can be used
Details for both types of command contexts are in the sections below.
Installation Context
The installation context is where your app was installed—to a guild, a user, or both. If your app supports both installation contexts, there may be cases where you want some of your app's commands to only be available for one or the other.
For example, maybe your app has a /profile command that is only relevant when it's installed to a user.
A command's supported installation context(s) can be set using the integration_types field when creating or updating a command as long as any included contexts are already supported by the application's integration_types.
Interaction Context
The interaction contexts for a command determines where it can be used, and can be configured by setting the contexts field when creating or updating a command.
There are three interaction context types that correspond to different surfaces: GUILD, BOT_DM, and PRIVATE_CHANNEL. However, the PRIVATE_CHANNEL interaction context is only meaningful for commands installed to a user (when the command's integration_types includes USER_INSTALL).
Permissions
Application command permissions allow commands to be configured on an individual basis for up to 100 users, roles, and channels within a guild.
A command's current permissions can be retrieved using the GET /applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions endpoint. The response will include a permissions arrau with associated IDs and permission types.
Command permissions can be updated with the PUT /applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissions endpoint by a user with sufficient permissions.
For their permissions to be considered sufficient, all of the following must be true:
- Has permission to
MANAGE_GUILDandMANAGE_ROLESin the guild where the command is being edited - Has the ability to run the command being edited
- Has permission to manage the resources that will be affected (roles, users, and/or channels depending on the permission types)
Application Command Permissions Object
Guild Application Command Permissions Structure
Returned when fetching the permissions for a command in a guild.
| Field | Type | Description |
|---|---|---|
| id 1 | snowflake | The ID of the command |
| application_id | snowflake | The ID of the application the command belongs to |
| guild_id | snowflake | The ID of the guild |
| permissions | array[application command permissions object] | The permissions for the command in the guild (max 100) |
1 When the id field is the application ID instead of a command ID, the permissions apply to all commands the application provides that do not otherwise have explicit overwrites.
Application Command Permissions Structure
Application command permissions allow you to enable or disable commands for specific users or roles within a guild.
| Field | Type | Description |
|---|---|---|
| id | snowflake | The ID of the role or user |
| type | integer | The type of the application command permission overwrite |
| permission | boolean | Whether the command is allowed to be invoked by the entity |
Application Command Permissions Constants
The following constants can be used in the id field for command permissions payloads.
| Permission | Value | Type | Description |
|---|---|---|---|
@everyone | guild_id | snowflake | All members in a guild |
| All Channels | guild_id - 1 | snowflake | All channels in a guild |
Application Command Permission Type
| Value | Name | Description |
|---|---|---|
| 1 | ROLE | A role within a guild |
| 2 | USER | A guild member |
| 3 | CHANNEL | A channel within a guild |
To allow for fine-tuned access to commands, application command permissions are supported for guild and global commands of all types. Guild members and apps with the necessary permissions can allow or deny specific users and roles from using a command, or toggle commands for entire channels.
Similar to how threads inherit user and role permissions from the parent channel, any command permissions for a channel will apply to the threads it contains.
Using Default Permissions
Default permissions can be added to a command during creation using the default_member_permissions and context fields. This is the only opportunity for bots to configure permissions on commands, as per-guild command permissions must be configured by a user account or through OAuth2.
The default_member_permissions field can be used when creating a command to set the permissions a user must have to use it.
The value for default_member_permissions is a bitwise OR-ed set of permissions, serialized as a string.
Setting it to 0 will prohibit anyone in a guild from using the command unless a specific overwrite is configured or the user has admin permissions.
You can also include BOT_DM in contexts when setting a global command's interaction contexts to control whether it can be run in DMs with your bot. Guild commands don't support the BOT_DM interaction context.
Example of Editing Permissions
Example of Editing Permissions
Simple example of editing command permissions
Example of Editing Permissions
Simple example of editing command permissions
As an example, the following command would not be usable by anyone except admins in any guilds by default:
{"name": "permissions_test","description": "A test of default permissions","type": 1,"default_member_permissions": "0"}
Or this would enable it just for users that have the MANAGE_GUILD permission:
And the following would disable a command for a specific channel:
Slash Commands
Slash commands—the CHAT_INPUT type—are a type of application command. They're made up of a name, description, and a block of options, which you can think of like arguments to a function.
The name and description help users find your command among many others, and the options validate user input as they fill out your command.
Slash commands can also have groups and subcommands to further organize commands. More on those later.
Example Slash Command
{"id": "1267261558183034922","application_id": "891436233903964161","version": "1267644402063507572","default_member_permissions": null,"type": 1,"name": "blep","description": "Send a random adorable animal photo","dm_permission": true,"contexts": [0, 1, 2],"integration_types": [0, 1],"options": [{"name": "animal","description": "The type of animal","type": 3,"required": true,"choices": [{"name": "Dog","value": "animal_dog"},{"name": "Cat","value": "animal_cat"},{"name": "Penguin","value": "animal_penguin"}]},{"name": "only_smol","description": "Whether to show only baby animals","type": 5,"required": false}],"nsfw": false}
When someone uses a slash command, your application will receive an interaction:
Example Slash Command Interaction
Slash Command Interaction
View sample payload for Slash Command interactions
Slash Command Interaction
View sample payload for Slash Command interactions
{"id": "786008729715212338","application_id": "775799577604522054","type": 2,"data": {"id": "1267261558183034922","name": "blep","options": [{"type": 3,"name": "animal","value": "animal_cat"},{"type": 5,"name": "only_smol","value": true}]},"guild": {"id": "290926798626357999","features": [],"locale": "en-US"},"channel": {"id": "645027906669510667","type": 0,"guild_id": "290926798626357999","position": 0,"name": "general","topic": null,"nsfw": false,"last_message_id": null,"rate_limit_per_user": 0,"parent_id": null,"last_pin_timestamp": null,"permissions": "2147483647","flags": 0,"icon_emoji": null,"theme_color": null},"channel_id": "645027906669510667","member": {"user": {"id": "53908232506183680","username": "mason","avatar": "a_d5efa99b3eeaa7dd43acca82f5692432","discriminator": "0","public_flags": 4325445,"banner": "42db4e3be824706cb1304fba05995722","accent_color": null,"global_name": "Mason","avatar_decoration_data": null,"collectibles": null,"display_name_styles": null,"primary_guild": null},"nick": null,"avatar": null,"avatar_decoration_data": null,"banner": null,"roles": ["539082325061836999"],"joined_at": "2017-03-13T19:19:14.040000+00:00","premium_since": null,"deaf": false,"mute": false,"pending": false,"communication_disabled_until": null,"unusual_dm_activity_until": null,"flags": 0,"permissions": "2147483647"},"token": "A_UNIQUE_TOKEN","version": 1,"app_permissions": "442368","locale": "en-US","guild_locale": "en-US","entitlements": [],"entitlement_sku_ids": [],"authorizing_integration_owners": {"0": "290926798626357999","1": "53908232506183680"},"attachment_size_limit": 524288000}
Subcommands and Subcommand Groups
For those developers looking to make more organized and complex groups of commands, look no further than subcommands and groups.
Subcommands organize your commands by specifying actions within a command or group.
Subcommand Groups organize your subcommands by grouping subcommands by similar action or resource within a command.
These are not enforced rules. You are free to use subcommands and groups however you'd like; it's just how Discord thinks about them.
Discord supports nesting one level deep within a group, meaning your top level command can contain subcommand groups, and those groups can contain subcommands. That is the only kind of nesting supported. Here's some visual examples:
Example Walkthrough
Example Walkthrough
View a moderation bot command example
Example Walkthrough
View a moderation bot command example
Let's look at an example. Let's imagine you run a moderation bot. You want to make a /permissions command that can do the following:
- Get the guild permissions for a user or a role
- Get the permissions for a user or a role on a specific channel
- Change the guild permissions for a user or a role
- Change the permissions for a user or a role on a specific channel
We'll start by defining the top-level information for /permissions:
Now we have a command named permissions. We want this command to be able to affect users and roles. Rather than making two separate commands, we can use subcommand groups. We want to use subcommand groups here because we are grouping commands on a similar resource: user or role.
You'll notice that a command like this will not show up in the command explorer. That's because groups are effectively "folders" for commands, and we've made two empty folders. So let's continue.
Now that we've effectively made user and role "folders", we want to be able to either get and edit permissions. Within the subcommand groups, we can make subcommands for get and edit:
Now, we need some arguments! If we chose user, we need to be able to pick a user; if we chose role, we need to be able to pick a role. We also want to be able to pick between guild-level permissions and channel-specific permissions. For that, we can use optional arguments:
And, done! The JSON looks a bit complicated, but what we've ended up with is a single command that can be scoped to multiple actions, and then further scoped to a particular resource, and then even further scope with optional arguments.
User Commands
User commands are application commands that appear on the context menu (right click or tap) of users. They're a great way to surface quick actions for your app that target users. They don't take any arguments, and will return the user on whom you clicked or tapped in the interaction response.
Example User Command
{"id": "1241360244118917161","application_id": "682654466453012553","version": "1263110356692373562","default_member_permissions": null,"type": 2,"name": "High Five","description": "","dm_permission": true,"contexts": [0, 1, 2],"integration_types": [1],"nsfw": false}
When someone uses a user command, your application will receive an interaction:
Example User Command Interaction
User Command Interaction
View sample payload for User Command interactions
User Command Interaction
View sample payload for User Command interactions
{"id": "867794291820986368","application_id": "775799577604522054","type": 2,"data": {"id": "1303493304175955988","name": "High Five","type": 2,"resolved": {"members": {"809850198683418695": {"nick": null,"avatar": null,"avatar_decoration_data": null,"banner": null,"roles": [],"joined_at": "2021-02-12T18:25:07.972000+00:00","premium_since": null,"pending": false,"communication_disabled_until": null,"unusual_dm_activity_until": null,"flags": 0,"permissions": "246997699136"}},"users": {"809850198683418695": {"id": "809850198683418695","username": "VoltyDemo","avatar": "afc428077119df8aabbbd84b0dc90c74","discriminator": "7302","public_flags": 524288,"bot": true,"banner": null,"accent_color": null,"global_name": null,"avatar_decoration_data": null,"collectibles": null,"display_name_styles": null,"primary_guild": null}}},"target_id": "809850198683418695"},"guild": {"id": "772904309264089089","features": [],"locale": "en-US"},"channel": {"id": "772908445358620702","type": 0,"guild_id": "772904309264089089","position": 0,"name": "general","topic": null,"nsfw": false,"last_message_id": null,"rate_limit_per_user": 0,"parent_id": null,"last_pin_timestamp": null,"permissions": "2147483647","flags": 0,"icon_emoji": null,"theme_color": null},"channel_id": "772908445358620702","member": {"user": {"id": "167348773423415296","username": "ian","avatar": "f61594630cbc4848cfe9d8da1a13088e","discriminator": "0","public_flags": 4604418,"banner": "6b9757e5926ac9f31d9e206581fc3cc3","accent_color": 16119261,"global_name": "ian","avatar_decoration_data": null,"collectibles": null,"display_name_styles": null,"primary_guild": null},"nick": null,"avatar": null,"avatar_decoration_data": null,"banner": null,"roles": ["785609923542777878"],"joined_at": "2020-11-02T20:46:57.364000+00:00","premium_since": null,"deaf": false,"mute": false,"pending": false,"communication_disabled_until": null,"unusual_dm_activity_until": null,"flags": 0,"permissions": "274877906943"},"token": "AN_UNIQUE_TOKEN","version": 1,"app_permissions": "442368","locale": "en-US","guild_locale": "en-US","entitlements": [],"entitlement_sku_ids": [],"authorizing_integration_owners": {"0": "772904309264089089","1": "167348773423415296"},"attachment_size_limit": 524288000}
Message Commands
Message commands are application commands that appear on the context menu (right click or tap) of messages. They're a great way to surface quick actions for your app that target messages. They don't take any arguments, and will return the message on whom you clicked or tapped in the interaction response.
Example Message Command
{"id": "1303493304175955988","application_id": "682654466453012553","version": "1303493304175955989","default_member_permissions": null,"type": 3,"name": "Bookmarks","description": "","dm_permission": true,"contexts": [0, 1, 2],"integration_types": [1],"nsfw": false}
When someone uses a message command, your application will receive an interaction:
Example Message Command Interaction
Message Command Interaction
View sample payload for Message Command interactions
Message Command Interaction
View sample payload for Message Command interactions
{"id": "867794291820986368","application_id": "775799577604522054","type": 2,"data": {"id": "1303493304175955988","name": "Bookmarks","type": 3,"resolved": {"messages": {"867793854505943041": {"id": "867793854505943041","channel_id": "772908445358620702","author": {"id": "167348773423415296","username": "ian","avatar": "f61594630cbc4848cfe9d8da1a13088e","discriminator": "0","public_flags": 4604418,"banner": "6b9757e5926ac9f31d9e206581fc3cc3","accent_color": 16119261,"global_name": "ian","avatar_decoration_data": null,"collectibles": null,"display_name_styles": null,"primary_guild": null},"content": "some message","timestamp": "2021-07-22T15:42:57.744000+00:00","edited_timestamp": null,"tts": false,"mention_everyone": false,"mentions": [],"mention_roles": [],"attachments": [],"embeds": [],"pinned": false,"type": 0,"flags": 0,"components": []}}},"target_id": "867793854505943041"},"guild": {"id": "772904309264089089","features": [],"locale": "en-US"},"channel": {"id": "772908445358620702","type": 0,"guild_id": "772904309264089089","position": 0,"name": "general","topic": null,"nsfw": false,"last_message_id": null,"rate_limit_per_user": 0,"parent_id": null,"last_pin_timestamp": null,"permissions": "2147483647","flags": 0,"icon_emoji": {"id": null,"name": "💬"},"theme_color": null},"channel_id": "772908445358620702","member": {"user": {"id": "167348773423415296","username": "ian","avatar": "f61594630cbc4848cfe9d8da1a13088e","discriminator": "0","public_flags": 4604418,"banner": "6b9757e5926ac9f31d9e206581fc3cc3","accent_color": 16119261,"global_name": "ian","avatar_decoration_data": null,"collectibles": null,"display_name_styles": null,"primary_guild": null},"nick": null,"avatar": null,"avatar_decoration_data": null,"banner": null,"roles": ["785609923542777878"],"joined_at": "2020-11-02T20:46:57.364000+00:00","premium_since": null,"deaf": false,"mute": false,"pending": false,"communication_disabled_until": null,"unusual_dm_activity_until": null,"flags": 0,"permissions": "274877906943"},"token": "AN_UNIQUE_TOKEN","version": 1,"app_permissions": "442368","locale": "en-US","guild_locale": "en-US","entitlements": [],"entitlement_sku_ids": [],"authorizing_integration_owners": {"0": "772904309264089089","1": "167348773423415296"},"attachment_size_limit": 524288000}
Entry Point Commands
An Entry Point command serves as the primary way for users to open an application's embedded activity.
For the Entry Point command to be visible to users, an app must have the EMBEDDED flag enabled.
Example Entry Point Command
{"id": "1277685617043439616","type": 4,"application_id": "1006584476094177371","version": "1277685617043439617","name": "launch","description": "Launch Racing with Friends","dm_permission": true,"contexts": [0, 1, 2],"integration_types": [0, 1],"handler": 2}
Entry Point Handlers
When a user invokes an app's Entry Point command, the value of handler will determine how the interaction is handled:
- For
APP_HANDLER, the application is responsible for responding to the interaction. It can respond by launching the app's associated embedded activity using theLAUNCH_ACTIVITYinteraction callback type, or take another action (like sending a follow-up message in channel). - For
DISCORD_LAUNCH_ACTIVITY, Discord will handle the interaction automatically by launching the associated embedded activity and sending a message to the channel where it was launched. - For
APP_HANDLER_LAUNCH_ACTIVITY, the application is again responsible for responding to the interaction, but it can only respond by launching the app's associated embedded activity using theLAUNCH_ACTIVITYinteraction callback type.
When embedded activities are enabled on an application, an Entry Point command (named "launch") is automatically created for your app with DISCORD_LAUNCH_ACTIVITY set as the Entry Point handler.
Autocomplete
Autocomplete interactions allow your application to dynamically return option suggestions to a user as they type.
An autocomplete interaction can return partial data for option values. Your application will receive partial data for any existing user input, as long as that input passes client-side validation.
For example, you may receive partial strings, but not invalid numbers. The option the user is currently typing will be sent with a focused: true boolean field and options the user has already filled will also be sent but without the focused field.
This is a special case where options that are otherwise required might not be present, due to the user not having filled them yet.
Localization
Application commands can be localized, which will cause them to use localized names and descriptions depending on the client's selected language. This is entirely optional.
Localization is available for names and descriptions of commands, subcommands, and options, as well as the names of choices, by submitting the appropriate name_localizations and description_localizations fields when creating or updating the application command.
Application commands may be partially localized—not all available locales are required, nor do different fields within a command need to support the same set of locales. If a locale is not present in a localizations dictionary for a field, users in that locale will see the default value for that field. It's not necessary to fill out all locales with the default value. Any localized values that are identical to the default will be ignored.
Localized option names are subject to an additional constraint, which is that they must be distinct from all other default option names of that command, as well as all other option names within that locale on that command.
When taking advantage of command localization, the interaction payload received by your client will still use default command, subcommand, and option names.
To localize your interaction response, you can determine the client's selected language by using the locale key in the interaction payload.
An application command furnished with localizations might look like this:
{"name": "birthday","type": 1,"description": "Wish a friend a happy birthday","name_localizations": {"zh-CN": "生日","el": "γενέθλια"},"description_localizations": {"zh-CN": "祝你朋友生日快乐"},"options": [{"name": "age","type": 4,"description": "Your friend's age","name_localizations": {"zh-CN": "岁数"},"description_localizations": {"zh-CN": "你朋友的岁数"}}]}
Locale Fallbacks
For application commands, there are built-in fallbacks in case a user's locale isn't present in the localizations. If the fallback locale is also missing, it will use the default.
| Locale | Fallback |
|---|---|
| en-US | en-GB |
| en-GB | en-US |
| es-419 | es-ES |
Retrieving Localized Commands
While most endpoints that return application command objects will return the name_localizations and description_localizations fields, some will not by default. This includes GET endpoints that return all of an application's guild or global commands. Instead, those endpoints will supply additional name_localized or description_localized fields, which only contain the localization relevant to the requester's locale. The full dictionaries can still be obtained by supplying the appropriate query argument.
For example, if a batch GET request were made with locale zh-CN, including the above command, the returned object would look as follows:
{"name": "birthday","type": 1,"description": "Wish a friend a happy birthday","name_localized": "生日","description_localized": "祝你朋友生日快乐","options": [{"name": "age","type": 4,"description": "Your friend's age","name_localized": "岁数","description_localized": "你朋友的岁数"}]}
If the requester's locale is not found in a localizations dictionary, then the corresponding name_localization or description_localization for that field will also not be present.
Locale is determined by looking at the X-Discord-Locale header, then the Accept-Language header if not present, then lastly the user settings locale.
Age-Restricted Commands
A command that contains age-restricted content should have the nsfw field set to true upon creation or update. Marking a command as age-restricted will limit who can see and access the command, and from which channels.
Using Age-Restricted Commands
To use an age-restricted command, a user must be 18 years or older and access the command from either:
- an age-restricted channel or
- a DM with the app after enabling age-restricted commands within their user settings.
Details about accessing and using age-restricted commands is in the Help Center.
Endpoints
Get Application Command Index
GET/applications/{application.id}/application-command-indexReturns an application command index object for the given application ID, containing all of the application's available commands. User must have the application authorized on their account.
Get Channel Application Command Index
GET/channels/{channel.id}/application-command-indexReturns an application command index object for the given private channel ID. In a bot DM, this will return the commands available from the application associated with the bot. In a group DM, it will query the integrations authorized to the channel.
Get Guild Application Command Index
GET/guilds/{guild.id}/application-command-indexReturns an application command index object for the given guild ID, containing the commands available from all applications installed to the guild. User must be a member of the guild.
Get User Application Command Index
GET/users/@me/application-command-indexReturns an application command index object for the current user, containing the commands available from all applications installed to the user's account.
Get Global Application Commands
GET/applications/{application.id}/commandsReturns a list of global application command objects for the given application ID. User must be the owner of the application, developer of the application's team, or have a DM channel with the application's bot.
Query String Params
| Field | Type | Description |
|---|---|---|
| with_localizations? | boolean | Whether to include full localization dictionaries (name_localizations and description_localizations) in the returned objects, instead of the name_localized and description_localized fields (default false) |
Create Global Application Command
POST/applications/{application.id}/commandsCreates a new global command. Returns an application command object on success.
JSON Params
| Field | Type | Description | Valid Types |
|---|---|---|---|
| type? | integer | The type of the command (default CHAT_INPUT) | All |
| name | string | The name of the option (1-32 characters) | All |
| name_localizations? | ?map[string, string] | The localized name for each locale (values follow same restrictions as name) | All |
| description? 1 | string | The description of the option (1-100 characters) | All |
| description_localizations? | ?map[string, string] | The localized description for each locale (values follow same restrictions as description) | All |
| options? | array[application command option object] | The options for the command (max 25) | CHAT_INPUT |
| default_member_permissions? | ?string | The default required permissions to call the command | All |
| dm_permission? (deprecated) | boolean | Whether the command is available in DMs with the application (default true) | All |
| nsfw? | boolean | Whether the command is age-restricted (default false) | All |
| integration_types? | array[integer] | The installation contexts where the command is available (default application's configured contexts) | All |
| contexts? | array[integer] | The interaction context where the command can be used | All |
| handler? | integer | How the command should be handled when called | PRIMARY_ENTRY_POINT |
1 Required for PRIMARY_ENTRY_POINT commands.
Get Global Application Command
GET/applications/{application.id}/commands/{command.id}Returns an application command object for the given application and command ID.
Modify Global Application Command
PATCH/applications/{application.id}/commands/{command.id}Modifies a global command. Returns the updated application command object on success.
JSON Params
| Field | Type | Description | Valid Types |
|---|---|---|---|
| name? | string | The name of the option (1-32 characters) | All |
| name_localizations? | ?map[string, string] | The localized name for each locale (values follow same restrictions as name) | All |
| description? | string | The description of the option (1-100 characters) | All |
| description_localizations? | ?map[string, string] | The localized description for each locale (values follow same restrictions as description) | All |
| options? | ?array[application command option object] | The options for the command (max 25) | CHAT_INPUT |
| default_member_permissions | ?string | The default required permissions to call the command | All |
| dm_permission? (deprecated) | ?boolean | Whether the command is available in DMs with the application | All |
| All | |||
| nsfw? | ?boolean | Whether the command is age-restricted | All |
| integration_types? | ?array[integer] | The installation contexts where the command is available (default application's configured contexts) | All |
| contexts? | ?array[integer] | The interaction context where the command can be used | All |
| handler? | ?integer | How the command should be handled when called | PRIMARY_ENTRY_POINT |
Delete Global Application Command
DELETE/applications/{application.id}/commands/{command.id}Deletes a global command. Returns a 204 empty response on success.
Bulk Modify Global Application Commands
PUT/applications/{application.id}/commandsOverwrites all existing commands that are registered globally for this application. Accepts a list of application command objects. Returns a list of application command objects on success. Commands that do not already exist will count toward daily application command create limits.
Get Guild Application Commands
GET/applications/{application.id}/guilds/{guild.id}/commandsReturns a list of application command objects for the given guild ID. User must be the owner of the application or developer of the application's team.
Query String Params
| Field | Type | Description |
|---|---|---|
| with_localizations? | boolean | Whether to include full localization dictionaries (name_localizations and description_localizations) in the returned objects, instead of the name_localized and description_localized fields (default false) |
Create Guild Application Command
POST/applications/{application.id}/guilds/{guild.id}/commandsCreates a new guild command. Returns an application command object. If the command did not already exist, it will count toward daily application command create limits.
JSON Params
| Field | Type | Description | Valid Types |
|---|---|---|---|
| type? | integer | The type of the command (default CHAT_INPUT) | All |
| name | string | The name of the option (1-32 characters) | All |
| name_localizations? | ?map[string, string] | The localized name for each locale (values follow same restrictions as name) | All |
| description | string | The description of the option (1-100 characters) | All |
| description_localizations? | ?map[string, string] | The localized description for each locale (values follow same restrictions as description) | All |
| options? | ?array[application command option object] | The options for the command (max 25) | CHAT_INPUT |
| default_member_permissions? | ?string | The default required permissions to call the command | All |
| nsfw? | boolean | Whether the command is age-restricted | All |
Get Guild Application Command
GET/applications/{application.id}/guilds/{guild.id}/commands/{command.id}Returns an application command object for the given application, guild, and command ID.
Modify Guild Application Command
PATCH/applications/{application.id}/guilds/{guild.id}/commands/{command.id}Modifies a guild command. Returns the updated guild application command object on success. Fires Guild Application Command Index Update Gateway event.
JSON Params
| Field | Type | Description | Valid Types |
|---|---|---|---|
| name? | string | The name of the option (1-32 characters) | All |
| name_localizations? | ?map[string, string] | The localized name for each locale (values follow same restrictions as name) | All |
| description? | string | The description of the option (1-100 characters) | All |
| description_localizations? | ?map[string, string] | The localized description for each locale (values follow same restrictions as description) | All |
| options? | ?array[application command option object] | The options for the command (max 25) | CHAT_INPUT |
| default_member_permissions? | ?string | The default required permissions to call the command | All |
| nsfw? | ?boolean | Whether the command is age-restricted | All |
Delete Guild Application Command
DELETE/applications/{application.id}/guilds/{guild.id}/commands/{command.id}Deletes a guild application command. Returns a 204 empty response on success.
Bulk Modify Guild Application Commands
PUT/applications/{application.id}/guilds/{guild.id}/commandsOverwrites all existing commands that are registered for the given guild. Accepts a list of application command objects. Returns a list of application command objects on success. Commands that do not already exist will count toward daily application command create limits.
Get Guild Application Command Permissions
GET/applications/{application.id}/guilds/{guild.id}/commands/permissionsReturns a list of guild application command permissions objects representing all configured command permissions for your application in a guild.
Get Application Command Permissions
GET/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissionsReturns a guild application command permissions object for a specific application command in a guild.
Modify Application Command Permissions
PUT/applications/{application.id}/guilds/{guild.id}/commands/{command.id}/permissionsReplaces permissions for a specific application command in a guild. Returns a guild application command permissions object on success. You can only add up to 10 permission overwrites for a command. Deleting or renaming a command will permanently delete all permissions for that command.
JSON Params
| Field | Type | Description |
|---|---|---|
| permissions | array[application command permissions object] | The permissions for the command in the guild |