dfx 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DiscordREST/types.js +6 -0
- package/DiscordREST/types.js.map +1 -0
- package/DiscordWS/index.js +2 -0
- package/DiscordWS/index.js.map +1 -0
- package/README.md +3 -0
- package/WS/index.js +71 -0
- package/WS/index.js.map +1 -0
- package/discord-api-docs/index.js +1 -0
- package/mod.js.map +1 -0
- package/package.json +6 -1
- package/types.js +1563 -0
- package/types.js.map +1 -0
- package/websocket.js +11 -0
- package/websocket.js.map +1 -0
- package/.gitmodules +0 -3
- package/.prettierrc.json +0 -4
- package/discord-api-docs/.eslintrc.json +0 -10
- package/discord-api-docs/.gitattributes +0 -11
- package/discord-api-docs/.github/ISSUE_TEMPLATE/api-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/config.yml +0 -20
- package/discord-api-docs/.github/ISSUE_TEMPLATE/developer-site-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/message-components-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/slash-command-bug-report.yml +0 -49
- package/discord-api-docs/.github/workflows/test.yaml +0 -45
- package/discord-api-docs/.prettierignore +0 -1
- package/discord-api-docs/.prettierrc.json +0 -15
- package/discord-api-docs/CODE_OF_CONDUCT.md +0 -75
- package/discord-api-docs/CONTRIBUTING.md +0 -16
- package/discord-api-docs/README.md +0 -35
- package/discord-api-docs/docs/Change_Log.md +0 -474
- package/discord-api-docs/docs/Intro.md +0 -48
- package/discord-api-docs/docs/Legal.md +0 -154
- package/discord-api-docs/docs/Policy.md +0 -81
- package/discord-api-docs/docs/Reference.md +0 -476
- package/discord-api-docs/docs/Store_Distribution_Agreement.md +0 -179
- package/discord-api-docs/docs/dispatch/Branches_and_Builds.md +0 -654
- package/discord-api-docs/docs/dispatch/Dispatch_and_You.md +0 -17
- package/discord-api-docs/docs/dispatch/Error_Codes.md +0 -26
- package/discord-api-docs/docs/dispatch/Field_Values.md +0 -48
- package/discord-api-docs/docs/dispatch/List_of_Commands.md +0 -315
- package/discord-api-docs/docs/game_and_server_management/Alpha_and_Beta_Testing.md +0 -52
- package/discord-api-docs/docs/game_and_server_management/How_to_Get_Your_Game_on_Discord.md +0 -110
- package/discord-api-docs/docs/game_and_server_management/Special_Channels.md +0 -38
- package/discord-api-docs/docs/game_sdk/Achievements.md +0 -405
- package/discord-api-docs/docs/game_sdk/Activities.md +0 -561
- package/discord-api-docs/docs/game_sdk/Applications.md +0 -237
- package/discord-api-docs/docs/game_sdk/Discord.md +0 -443
- package/discord-api-docs/docs/game_sdk/Discord_Voice.md +0 -289
- package/discord-api-docs/docs/game_sdk/Images.md +0 -196
- package/discord-api-docs/docs/game_sdk/Lobbies.md +0 -1639
- package/discord-api-docs/docs/game_sdk/Networking.md +0 -377
- package/discord-api-docs/docs/game_sdk/Overlay.md +0 -195
- package/discord-api-docs/docs/game_sdk/Relationships.md +0 -234
- package/discord-api-docs/docs/game_sdk/SDK_Starter_Guide.md +0 -310
- package/discord-api-docs/docs/game_sdk/Storage.md +0 -312
- package/discord-api-docs/docs/game_sdk/Store.md +0 -555
- package/discord-api-docs/docs/game_sdk/Users.md +0 -178
- package/discord-api-docs/docs/interactions/Application_Commands.md +0 -1069
- package/discord-api-docs/docs/interactions/Message_Components.md +0 -454
- package/discord-api-docs/docs/interactions/Receiving_and_Responding.md +0 -372
- package/discord-api-docs/docs/interactions/Slash_Commands.md +0 -3
- package/discord-api-docs/docs/resources/Application.md +0 -82
- package/discord-api-docs/docs/resources/Audit_Log.md +0 -223
- package/discord-api-docs/docs/resources/Channel.md +0 -1267
- package/discord-api-docs/docs/resources/Emoji.md +0 -122
- package/discord-api-docs/docs/resources/Guild.md +0 -1157
- package/discord-api-docs/docs/resources/Guild_Scheduled_Event.md +0 -273
- package/discord-api-docs/docs/resources/Guild_Template.md +0 -148
- package/discord-api-docs/docs/resources/Invite.md +0 -150
- package/discord-api-docs/docs/resources/Stage_Instance.md +0 -106
- package/discord-api-docs/docs/resources/Sticker.md +0 -164
- package/discord-api-docs/docs/resources/User.md +0 -205
- package/discord-api-docs/docs/resources/Voice.md +0 -55
- package/discord-api-docs/docs/resources/Webhook.md +0 -281
- package/discord-api-docs/docs/rich_presence/Best_Practices.md +0 -88
- package/discord-api-docs/docs/rich_presence/FAQ.md +0 -45
- package/discord-api-docs/docs/rich_presence/How_To.md +0 -302
- package/discord-api-docs/docs/rich_presence/Launch_Checklist.md +0 -46
- package/discord-api-docs/docs/topics/Certified_Devices.md +0 -200
- package/discord-api-docs/docs/topics/Community_Resources.md +0 -98
- package/discord-api-docs/docs/topics/Gateway.md +0 -1600
- package/discord-api-docs/docs/topics/OAuth2.md +0 -427
- package/discord-api-docs/docs/topics/Opcodes_and_Status_Codes.md +0 -306
- package/discord-api-docs/docs/topics/Permissions.md +0 -229
- package/discord-api-docs/docs/topics/RPC.md +0 -1597
- package/discord-api-docs/docs/topics/Rate_Limits.md +0 -126
- package/discord-api-docs/docs/topics/Teams.md +0 -80
- package/discord-api-docs/docs/topics/Threads.md +0 -163
- package/discord-api-docs/docs/topics/Voice_Connections.md +0 -282
- package/discord-api-docs/images/API_center.gif +0 -0
- package/discord-api-docs/images/ask-to-join.gif +0 -0
- package/discord-api-docs/images/available-published.png +0 -0
- package/discord-api-docs/images/button-styles.png +0 -0
- package/discord-api-docs/images/certified-device.png +0 -0
- package/discord-api-docs/images/command-with-groups-subcommands-parameters.png +0 -0
- package/discord-api-docs/images/command-with-groups-subcommands.png +0 -0
- package/discord-api-docs/images/command.png +0 -0
- package/discord-api-docs/images/cpp-files-sdk.png +0 -0
- package/discord-api-docs/images/create-store-channel.png +0 -0
- package/discord-api-docs/images/deferred-example.png +0 -0
- package/discord-api-docs/images/desktop-select.png +0 -0
- package/discord-api-docs/images/game-overlay-sdk-invite.gif +0 -0
- package/discord-api-docs/images/game-overlay-sdk-voice-settings.png +0 -0
- package/discord-api-docs/images/game-overlay-sdk-voice-widget.png +0 -0
- package/discord-api-docs/images/gift-code-creation.png +0 -0
- package/discord-api-docs/images/lib-linked-sdk.png +0 -0
- package/discord-api-docs/images/message-command.png +0 -0
- package/discord-api-docs/images/mobile-select.png +0 -0
- package/discord-api-docs/images/previous-new-server-background.png +0 -0
- package/discord-api-docs/images/rp-actionable.png +0 -0
- package/discord-api-docs/images/rp-all-fields.png +0 -0
- package/discord-api-docs/images/rp-bad-art.png +0 -0
- package/discord-api-docs/images/rp-good-art.png +0 -0
- package/discord-api-docs/images/rp-legend.png +0 -0
- package/discord-api-docs/images/rp-long-strings.png +0 -0
- package/discord-api-docs/images/rp-non-actionable.png +0 -0
- package/discord-api-docs/images/rp-not-all-fields.png +0 -0
- package/discord-api-docs/images/rp-profile-example-1.png +0 -0
- package/discord-api-docs/images/rp-profile-example-2.png +0 -0
- package/discord-api-docs/images/rp-short-strings.png +0 -0
- package/discord-api-docs/images/server-banner-example.png +0 -0
- package/discord-api-docs/images/server-banner-margin-top.png +0 -0
- package/discord-api-docs/images/sku-management.png +0 -0
- package/discord-api-docs/images/snowflake.png +0 -0
- package/discord-api-docs/images/snowflake_original_size.png +0 -0
- package/discord-api-docs/images/spectate.gif +0 -0
- package/discord-api-docs/images/team-2fa.png +0 -0
- package/discord-api-docs/images/team-make-app.png +0 -0
- package/discord-api-docs/images/team-page.png +0 -0
- package/discord-api-docs/images/transfer-app-to-team.png +0 -0
- package/discord-api-docs/images/user-command.png +0 -0
- package/discord-api-docs/package-lock.json +0 -3186
- package/discord-api-docs/package.json +0 -38
- package/discord-api-docs/tsconfig.eslint.json +0 -4
- package/discord-api-docs/tsconfig.json +0 -19
- package/tsconfig.json +0 -24
|
@@ -1,1069 +0,0 @@
|
|
|
1
|
-
# Application Commands
|
|
2
|
-
|
|
3
|
-
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.
|
|
4
|
-
|
|
5
|
-
## Application Command Object
|
|
6
|
-
|
|
7
|
-
###### Application Command Naming
|
|
8
|
-
|
|
9
|
-
`CHAT_INPUT` command names and command option names must match the following regex `^[\w-]{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/or uncased letters are still allowed. `USER` and `MESSAGE` commands may be mixed case and can include spaces.
|
|
10
|
-
|
|
11
|
-
###### Application Command Structure
|
|
12
|
-
|
|
13
|
-
| Field | Type | Description | Valid Types |
|
|
14
|
-
|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|-------------|
|
|
15
|
-
| id | snowflake | unique id of the command | all |
|
|
16
|
-
| type? | one of [application command type](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-types) | the type of command, defaults `1` if not set | all |
|
|
17
|
-
| application_id | snowflake | unique id of the parent application | all |
|
|
18
|
-
| guild_id? | snowflake | guild id of the command, if not global | all |
|
|
19
|
-
| name | string | [1-32 character name](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-naming) | all |
|
|
20
|
-
| description | string | 1-100 character description for `CHAT_INPUT` commands, empty string for `USER` and `MESSAGE` commands | all |
|
|
21
|
-
| options? | array of [application command option](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-structure) | the parameters for the command, max 25 | CHAT_INPUT |
|
|
22
|
-
| default_permission? | boolean (default `true`) | whether the command is enabled by default when the app is added to a guild | all |
|
|
23
|
-
| version | snowflake | autoincrementing version identifier updated during substantial record changes | all |
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
###### Application Command Types
|
|
27
|
-
|
|
28
|
-
| Name | Type | Description |
|
|
29
|
-
| ---------- | ---- | ------------------------------------------------------------------------- |
|
|
30
|
-
| CHAT_INPUT | 1 | Slash commands; a text-based command that shows up when a user types `/` |
|
|
31
|
-
| USER | 2 | A UI-based command that shows up when you right click or tap on a user |
|
|
32
|
-
| MESSAGE | 3 | A UI-based command that shows up when you right click or tap on a message |
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
###### Application Command Option Structure
|
|
36
|
-
|
|
37
|
-
> warn
|
|
38
|
-
> Required `options` must be listed before optional options
|
|
39
|
-
|
|
40
|
-
| Field | Type | Description |
|
|
41
|
-
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
|
42
|
-
| type | one of [application command option type](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-type) | the type of option |
|
|
43
|
-
| name | string | [1-32 character name](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-naming) |
|
|
44
|
-
| description | string | 1-100 character description |
|
|
45
|
-
| required? | boolean | if the parameter is required or optional--default `false` |
|
|
46
|
-
| choices? | array of [application command option choice](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-choice-structure) | choices for `STRING`, `INTEGER`, and `NUMBER` types for the user to pick from, max 25 |
|
|
47
|
-
| options? | array of [application command option](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-structure) | if the option is a subcommand or subcommand group type, these nested options will be the parameters |
|
|
48
|
-
| channel_types? | array of [channel types](#DOCS_RESOURCES_CHANNEL/channel-object-channel-types) | if the option is a channel type, the channels shown will be restricted to these types |
|
|
49
|
-
| min_value? | integer for `INTEGER` options, double for `NUMBER` options | if the option is an `INTEGER` or `NUMBER` type, the minimum value permitted |
|
|
50
|
-
| max_value? | integer for `INTEGER` options, double for `NUMBER` options | if the option is an `INTEGER` or `NUMBER` type, the maximum value permitted |
|
|
51
|
-
| autocomplete? \* | boolean | if autocomplete interactions are enabled for this `STRING`, `INTEGER`, or `NUMBER` type option |
|
|
52
|
-
|
|
53
|
-
\* `autocomplete` may not be set to true if `choices` are present.
|
|
54
|
-
|
|
55
|
-
> note
|
|
56
|
-
> Options using `autocomplete` are not confined to only use choices given by the application.
|
|
57
|
-
|
|
58
|
-
###### Application Command Option Type
|
|
59
|
-
|
|
60
|
-
| Name | Value | Note |
|
|
61
|
-
| ----------------- | ----- | -------------------------------------------------------------- |
|
|
62
|
-
| SUB_COMMAND | 1 | |
|
|
63
|
-
| SUB_COMMAND_GROUP | 2 | |
|
|
64
|
-
| STRING | 3 | |
|
|
65
|
-
| INTEGER | 4 | Any integer between -2^53 and 2^53 |
|
|
66
|
-
| BOOLEAN | 5 | |
|
|
67
|
-
| USER | 6 | |
|
|
68
|
-
| CHANNEL | 7 | Includes all channel types + categories |
|
|
69
|
-
| ROLE | 8 | |
|
|
70
|
-
| MENTIONABLE | 9 | Includes users and roles |
|
|
71
|
-
| NUMBER | 10 | Any double between -2^53 and 2^53 |
|
|
72
|
-
| ATTACHMENT | 11 | [attachment](#DOCS_RESOURCES_CHANNEL/attachment-object) object |
|
|
73
|
-
|
|
74
|
-
###### Application Command Option Choice Structure
|
|
75
|
-
|
|
76
|
-
If you specify `choices` for an option, they are the **only** valid values for a user to pick
|
|
77
|
-
|
|
78
|
-
| Field | Type | Description |
|
|
79
|
-
| ----- | ----------------------------- | --------------------------------------------------- |
|
|
80
|
-
| name | string | 1-100 character choice name |
|
|
81
|
-
| value | string, integer, or double \* | value of the choice, up to 100 characters if string |
|
|
82
|
-
|
|
83
|
-
\* Type of `value` depends on the [option type](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-type) that the choice belongs to.
|
|
84
|
-
|
|
85
|
-
###### Application Command Interaction Data Option Structure
|
|
86
|
-
|
|
87
|
-
All options have names, and an option can either be a parameter and input value--in which case `value` will be set--or it can denote a subcommand or group--in which case it will contain a top-level key and another array of `options`.
|
|
88
|
-
|
|
89
|
-
`value` and `options` are mutually exclusive.
|
|
90
|
-
|
|
91
|
-
| Field | Type | Description |
|
|
92
|
-
| -------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
93
|
-
| name | string | the name of the parameter |
|
|
94
|
-
| type | integer | value of [application command option type](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-type) |
|
|
95
|
-
| value? | string, integer, or double | the value of the option resulting from user input |
|
|
96
|
-
| options? | array of [application command interaction data option](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-interaction-data-option-structure) | present if this option is a group or subcommand |
|
|
97
|
-
| focused? | boolean | true if this option is the currently focused option for autocomplete |
|
|
98
|
-
|
|
99
|
-
## Authorizing Your Application
|
|
100
|
-
|
|
101
|
-
Application commands do not depend on a bot user in the guild; they use the [interactions](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/) model. To create commands in a guild, your app must be authorized with the `applications.commands` scope.
|
|
102
|
-
|
|
103
|
-
> danger
|
|
104
|
-
> **In order to make commands work within a guild, the guild must authorize your application with the `applications.commands` scope. The `bot` scope is not enough.**
|
|
105
|
-
|
|
106
|
-
When requesting this scope, we "shortcut" the OAuth2 flow similar to adding a bot. You don't need to complete the flow, exchange for a token, or any of that.
|
|
107
|
-
|
|
108
|
-
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**.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
## Registering a Command
|
|
112
|
-
|
|
113
|
-
> info
|
|
114
|
-
> Commands can only be registered via HTTP endpoint.
|
|
115
|
-
|
|
116
|
-
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.
|
|
117
|
-
|
|
118
|
-
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:
|
|
119
|
-
|
|
120
|
-
- Your app **cannot** have two global `CHAT_INPUT` commands with the same name
|
|
121
|
-
- Your app **cannot** have two guild `CHAT_INPUT` commands within the same name **on the same guild**
|
|
122
|
-
- Your app **cannot** have two global `USER` commands with the same name
|
|
123
|
-
- Your app **can** have a global and guild `CHAT_INPUT` command with the same name
|
|
124
|
-
- Your app **can** have a global `CHAT_INPUT` and `USER` command with the same name
|
|
125
|
-
- Multiple apps **can** have commands with the same names
|
|
126
|
-
|
|
127
|
-
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).
|
|
128
|
-
|
|
129
|
-
An app can have the following number of commands:
|
|
130
|
-
|
|
131
|
-
- 100 global `CHAT_INPUT` commands
|
|
132
|
-
- 5 global `USER` commands
|
|
133
|
-
- 5 global `MESSAGE` commands
|
|
134
|
-
|
|
135
|
-
As well as the same amount of guild-specific commands per guild.
|
|
136
|
-
|
|
137
|
-
> danger
|
|
138
|
-
> There is a global rate limit of 200 application command creates per day, per guild
|
|
139
|
-
|
|
140
|
-
### Making a Global Command
|
|
141
|
-
|
|
142
|
-
Global commands are available on _all_ your app's guilds. Global commands are cached for **1 hour**. That means that new global commands will fan out slowly across all guilds, and will be guaranteed to be updated in an hour.
|
|
143
|
-
|
|
144
|
-
Global commands have inherent read-repair functionality. That means that if you make an update to a global command, and a 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.
|
|
145
|
-
|
|
146
|
-
To make a **global** command, make an HTTP POST call like this:
|
|
147
|
-
|
|
148
|
-
```py
|
|
149
|
-
import requests
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
url = "https://discord.com/api/v8/applications/<my_application_id>/commands"
|
|
153
|
-
|
|
154
|
-
# This is an example CHAT_INPUT or Slash Command, with a type of 1
|
|
155
|
-
json = {
|
|
156
|
-
"name": "blep",
|
|
157
|
-
"type": 1,
|
|
158
|
-
"description": "Send a random adorable animal photo",
|
|
159
|
-
"options": [
|
|
160
|
-
{
|
|
161
|
-
"name": "animal",
|
|
162
|
-
"description": "The type of animal",
|
|
163
|
-
"type": 3,
|
|
164
|
-
"required": True,
|
|
165
|
-
"choices": [
|
|
166
|
-
{
|
|
167
|
-
"name": "Dog",
|
|
168
|
-
"value": "animal_dog"
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
"name": "Cat",
|
|
172
|
-
"value": "animal_cat"
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
"name": "Penguin",
|
|
176
|
-
"value": "animal_penguin"
|
|
177
|
-
}
|
|
178
|
-
]
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"name": "only_smol",
|
|
182
|
-
"description": "Whether to show only baby animals",
|
|
183
|
-
"type": 5,
|
|
184
|
-
"required": False
|
|
185
|
-
}
|
|
186
|
-
]
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
# For authorization, you can use either your bot token
|
|
190
|
-
headers = {
|
|
191
|
-
"Authorization": "Bot <my_bot_token>"
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
# or a client credentials token for your app with the applications.commands.update scope
|
|
195
|
-
headers = {
|
|
196
|
-
"Authorization": "Bearer <my_credentials_token>"
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
r = requests.post(url, headers=headers, json=json)
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Making a Guild Command
|
|
203
|
-
|
|
204
|
-
Guild commands are available only within the guild specified on creation. Guild commands update **instantly**. We recommend you use guild commands for quick testing, and global commands when they're ready for public use.
|
|
205
|
-
|
|
206
|
-
To make a **guild** command, make a similar HTTP POST call, but scope it to a specific `guild_id`:
|
|
207
|
-
|
|
208
|
-
```py
|
|
209
|
-
import requests
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
url = "https://discord.com/api/v8/applications/<my_application_id>/guilds/<guild_id>/commands"
|
|
213
|
-
|
|
214
|
-
# This is an example USER command, with a type of 2
|
|
215
|
-
json = {
|
|
216
|
-
"name": "High Five",
|
|
217
|
-
"type": 2
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
# For authorization, you can use either your bot token
|
|
221
|
-
headers = {
|
|
222
|
-
"Authorization": "Bot <my_bot_token>"
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
# or a client credentials token for your app with the applications.commands.update scope
|
|
226
|
-
headers = {
|
|
227
|
-
"Authorization": "Bearer <my_credentials_token>"
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
r = requests.post(url, headers=headers, json=json)
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
## Updating and Deleting a Command
|
|
234
|
-
|
|
235
|
-
Commands can be deleted and updated by making `DELETE` and `PATCH` calls to the command endpoint. Those endpoints are
|
|
236
|
-
|
|
237
|
-
- `applications/<my_application_id>/commands/<command_id>` for global commands, or
|
|
238
|
-
- `applications/<my_application_id>/guilds/<guild_id>/commands/<command_id>` for guild commands
|
|
239
|
-
|
|
240
|
-
Because commands have unique names within a type and scope, we treat `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**.
|
|
241
|
-
|
|
242
|
-
Full documentation of endpoints can be found [here](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/endpoints).
|
|
243
|
-
|
|
244
|
-
## Permissions
|
|
245
|
-
|
|
246
|
-
### Application Command Permissions Object
|
|
247
|
-
|
|
248
|
-
###### Guild Application Command Permissions Structure
|
|
249
|
-
|
|
250
|
-
Returned when fetching the permissions for a command in a guild.
|
|
251
|
-
|
|
252
|
-
| Field | Type | Description |
|
|
253
|
-
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
|
|
254
|
-
| id | snowflake | the id of the command |
|
|
255
|
-
| application_id | snowflake | the id of the application the command belongs to |
|
|
256
|
-
| guild_id | snowflake | the id of the guild |
|
|
257
|
-
| permissions | array of [application command permissions](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-permissions-object-application-command-permissions-structure) | the permissions for the command in the guild |
|
|
258
|
-
|
|
259
|
-
###### Application Command Permissions Structure
|
|
260
|
-
|
|
261
|
-
Application command permissions allow you to enable or disable commands for specific users or roles within a guild.
|
|
262
|
-
|
|
263
|
-
| Field | Type | Description |
|
|
264
|
-
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
|
|
265
|
-
| id | snowflake | the id of the role or user |
|
|
266
|
-
| type | [application command permission type](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-permissions-object-application-command-permission-type) | role or user |
|
|
267
|
-
| permission | boolean | `true` to allow, `false`, to disallow |
|
|
268
|
-
|
|
269
|
-
###### Application Command Permission Type
|
|
270
|
-
|
|
271
|
-
| Name | Value |
|
|
272
|
-
| ---- | ----- |
|
|
273
|
-
| ROLE | 1 |
|
|
274
|
-
| USER | 2 |
|
|
275
|
-
|
|
276
|
-
Need to keep some of your commands safe from prying eyes, or only available to the right people? Commands support permission overwrites! For both guild _and_ global commands of all types, you can enable or disable a specific user or role in a guild from using a command.
|
|
277
|
-
|
|
278
|
-
> info
|
|
279
|
-
> For now, if you don't have permission to use a command, they'll show up in the command picker as disabled and unusable. They will **not** be hidden.
|
|
280
|
-
|
|
281
|
-
You can also set a `default_permission` on your commands if you want them to be disabled by default when your app is added to a new guild. Setting `default_permission` to `false` will disallow _anyone_ in a guild from using the command, unless a specific overwrite is configured. It will also disable the command from being usable in DMs.
|
|
282
|
-
|
|
283
|
-
For example, this command will not be usable by anyone in any guilds by default:
|
|
284
|
-
|
|
285
|
-
```json
|
|
286
|
-
{
|
|
287
|
-
"name": "permissions_test",
|
|
288
|
-
"description": "A test of default permissions",
|
|
289
|
-
"type": 1,
|
|
290
|
-
"default_permission": false
|
|
291
|
-
}
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
To enable it just for a moderator role:
|
|
295
|
-
|
|
296
|
-
```py
|
|
297
|
-
MODERATOR_ROLE_ID = "<moderator_role_id>"
|
|
298
|
-
url = "https://discord.com/api/v8/applications/<my_application_id>/guilds/<my_guild_id>/commands/<my_command_id>/permissions"
|
|
299
|
-
|
|
300
|
-
json = {
|
|
301
|
-
"permissions": [
|
|
302
|
-
{
|
|
303
|
-
"id": MODERATOR_ROLE_ID,
|
|
304
|
-
"type": 1,
|
|
305
|
-
"permission": True
|
|
306
|
-
}
|
|
307
|
-
]
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
headers = {
|
|
311
|
-
"Authorization": "Bot <my_bot_token>"
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
r = requests.put(url, headers=headers, json=json)
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
## Slash Commands
|
|
318
|
-
|
|
319
|
-
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.
|
|
320
|
-
|
|
321
|
-
Slash commands can also have groups and subcommands to further organize commands. More on those later.
|
|
322
|
-
|
|
323
|
-
> warn
|
|
324
|
-
> Slash commands can have a maximum of 4000 characters for combined name, description, and value properties for each command and its subcommands and groups
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
###### Example Slash Command
|
|
328
|
-
|
|
329
|
-
```json
|
|
330
|
-
{
|
|
331
|
-
"name": "blep",
|
|
332
|
-
"type": 1,
|
|
333
|
-
"description": "Send a random adorable animal photo",
|
|
334
|
-
"options": [
|
|
335
|
-
{
|
|
336
|
-
"name": "animal",
|
|
337
|
-
"description": "The type of animal",
|
|
338
|
-
"type": 3,
|
|
339
|
-
"required": true,
|
|
340
|
-
"choices": [
|
|
341
|
-
{
|
|
342
|
-
"name": "Dog",
|
|
343
|
-
"value": "animal_dog"
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
"name": "Cat",
|
|
347
|
-
"value": "animal_cat"
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
"name": "Penguin",
|
|
351
|
-
"value": "animal_penguin"
|
|
352
|
-
}
|
|
353
|
-
]
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
"name": "only_smol",
|
|
357
|
-
"description": "Whether to show only baby animals",
|
|
358
|
-
"type": 5,
|
|
359
|
-
"required": false
|
|
360
|
-
}
|
|
361
|
-
]
|
|
362
|
-
}
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
When someone uses a slash command, your application will receive an interaction:
|
|
366
|
-
|
|
367
|
-
###### Example Interaction
|
|
368
|
-
|
|
369
|
-
```js
|
|
370
|
-
{
|
|
371
|
-
"type": 2,
|
|
372
|
-
"token": "A_UNIQUE_TOKEN",
|
|
373
|
-
"member": {
|
|
374
|
-
"user": {
|
|
375
|
-
"id": "53908232506183680",
|
|
376
|
-
"username": "Mason",
|
|
377
|
-
"avatar": "a_d5efa99b3eeaa7dd43acca82f5692432",
|
|
378
|
-
"discriminator": "1337",
|
|
379
|
-
"public_flags": 131141
|
|
380
|
-
},
|
|
381
|
-
"roles": ["539082325061836999"],
|
|
382
|
-
"premium_since": null,
|
|
383
|
-
"permissions": "2147483647",
|
|
384
|
-
"pending": false,
|
|
385
|
-
"nick": null,
|
|
386
|
-
"mute": false,
|
|
387
|
-
"joined_at": "2017-03-13T19:19:14.040000+00:00",
|
|
388
|
-
"is_pending": false,
|
|
389
|
-
"deaf": false
|
|
390
|
-
},
|
|
391
|
-
"id": "786008729715212338",
|
|
392
|
-
"guild_id": "290926798626357999",
|
|
393
|
-
"data": {
|
|
394
|
-
"options": [{
|
|
395
|
-
"name": "cardname",
|
|
396
|
-
"value": "The Gitrog Monster"
|
|
397
|
-
}],
|
|
398
|
-
"name": "cardsearch",
|
|
399
|
-
"id": "771825006014889984"
|
|
400
|
-
},
|
|
401
|
-
"channel_id": "645027906669510667"
|
|
402
|
-
}
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
## Subcommands and Subcommand Groups
|
|
406
|
-
|
|
407
|
-
> warn
|
|
408
|
-
> Currently, subcommands and subcommand groups all appear at the top level in the command explorer. This may change in the future to include them as nested autocomplete options.
|
|
409
|
-
|
|
410
|
-
For those developers looking to make more organized and complex groups of commands, look no further than subcommands and groups.
|
|
411
|
-
|
|
412
|
-
**Subcommands** organize your commands by **specifying actions within a command or group**.
|
|
413
|
-
|
|
414
|
-
**Subcommand Groups** organize your **subcommands** by **grouping subcommands by similar action or resource within a command**.
|
|
415
|
-
|
|
416
|
-
These are not enforced rules. You are free to use subcommands and groups however you'd like; it's just how we think about them.
|
|
417
|
-
|
|
418
|
-
> danger
|
|
419
|
-
> Using subcommands or subcommand groups will make your base command unusable. You can't send the base `/permissions` command as a valid command if you also have `/permissions add | remove` as subcommands or subcommand groups
|
|
420
|
-
|
|
421
|
-
We support 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:
|
|
422
|
-
|
|
423
|
-
```
|
|
424
|
-
VALID
|
|
425
|
-
|
|
426
|
-
command
|
|
427
|
-
|
|
|
428
|
-
|__ subcommand
|
|
429
|
-
|
|
|
430
|
-
|__ subcommand
|
|
431
|
-
|
|
432
|
-
----
|
|
433
|
-
|
|
434
|
-
VALID
|
|
435
|
-
|
|
436
|
-
command
|
|
437
|
-
|
|
|
438
|
-
|__ subcommand-group
|
|
439
|
-
|
|
|
440
|
-
|__ subcommand
|
|
441
|
-
|
|
|
442
|
-
|__ subcommand-group
|
|
443
|
-
|
|
|
444
|
-
|__ subcommand
|
|
445
|
-
|
|
446
|
-
----
|
|
447
|
-
|
|
448
|
-
VALID
|
|
449
|
-
|
|
450
|
-
command
|
|
451
|
-
|
|
|
452
|
-
|__ subcommand-group
|
|
453
|
-
|
|
|
454
|
-
|__ subcommand
|
|
455
|
-
|
|
|
456
|
-
|__ subcommand
|
|
457
|
-
|
|
458
|
-
-------
|
|
459
|
-
|
|
460
|
-
INVALID
|
|
461
|
-
|
|
462
|
-
command
|
|
463
|
-
|
|
|
464
|
-
|__ subcommand-group
|
|
465
|
-
|
|
|
466
|
-
|__ subcommand-group
|
|
467
|
-
|
|
|
468
|
-
|__ subcommand-group
|
|
469
|
-
|
|
|
470
|
-
|__ subcommand-group
|
|
471
|
-
|
|
472
|
-
----
|
|
473
|
-
|
|
474
|
-
INVALID
|
|
475
|
-
|
|
476
|
-
command
|
|
477
|
-
|
|
|
478
|
-
|__ subcommand
|
|
479
|
-
|
|
|
480
|
-
|__ subcommand-group
|
|
481
|
-
|
|
|
482
|
-
|__ subcommand
|
|
483
|
-
|
|
|
484
|
-
|__ subcommand-group
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
### Example Walkthrough
|
|
488
|
-
|
|
489
|
-
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:
|
|
490
|
-
|
|
491
|
-
- Get the guild permissions for a user or a role
|
|
492
|
-
- Get the permissions for a user or a role on a specific channel
|
|
493
|
-
- Change the guild permissions for a user or a role
|
|
494
|
-
- Change the permissions for a user or a role on a specific channel
|
|
495
|
-
|
|
496
|
-
We'll start by defining the top-level information for `/permissions`:
|
|
497
|
-
|
|
498
|
-
```js
|
|
499
|
-
{
|
|
500
|
-
"name": "permissions",
|
|
501
|
-
"description": "Get or edit permissions for a user or a role",
|
|
502
|
-
"options": []
|
|
503
|
-
}
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-

|
|
507
|
-
|
|
508
|
-
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`.
|
|
509
|
-
|
|
510
|
-
```js
|
|
511
|
-
{
|
|
512
|
-
"name": "permissions",
|
|
513
|
-
"description": "Get or edit permissions for a user or a role",
|
|
514
|
-
"options": [
|
|
515
|
-
{
|
|
516
|
-
"name": "user",
|
|
517
|
-
"description": "Get or edit permissions for a user",
|
|
518
|
-
"type": 2 // 2 is type SUB_COMMAND_GROUP
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
"name": "role",
|
|
522
|
-
"description": "Get or edit permissions for a role",
|
|
523
|
-
"type": 2
|
|
524
|
-
}
|
|
525
|
-
]
|
|
526
|
-
}
|
|
527
|
-
```
|
|
528
|
-
|
|
529
|
-
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.
|
|
530
|
-
|
|
531
|
-
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`:
|
|
532
|
-
|
|
533
|
-
```js
|
|
534
|
-
{
|
|
535
|
-
"name": "permissions",
|
|
536
|
-
"description": "Get or edit permissions for a user or a role",
|
|
537
|
-
"options": [
|
|
538
|
-
{
|
|
539
|
-
"name": "user",
|
|
540
|
-
"description": "Get or edit permissions for a user",
|
|
541
|
-
"type": 2, // 2 is type SUB_COMMAND_GROUP
|
|
542
|
-
"options": [
|
|
543
|
-
{
|
|
544
|
-
"name": "get",
|
|
545
|
-
"description": "Get permissions for a user",
|
|
546
|
-
"type": 1 // 1 is type SUB_COMMAND
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
"name": "edit",
|
|
550
|
-
"description": "Edit permissions for a user",
|
|
551
|
-
"type": 1
|
|
552
|
-
}
|
|
553
|
-
]
|
|
554
|
-
},
|
|
555
|
-
{
|
|
556
|
-
"name": "role",
|
|
557
|
-
"description": "Get or edit permissions for a role",
|
|
558
|
-
"type": 2,
|
|
559
|
-
"options": [
|
|
560
|
-
{
|
|
561
|
-
"name": "get",
|
|
562
|
-
"description": "Get permissions for a role",
|
|
563
|
-
"type": 1
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
"name": "edit",
|
|
567
|
-
"description": "Edit permissions for a role",
|
|
568
|
-
"type": 1
|
|
569
|
-
}
|
|
570
|
-
]
|
|
571
|
-
}
|
|
572
|
-
]
|
|
573
|
-
}
|
|
574
|
-
```
|
|
575
|
-
|
|
576
|
-

|
|
577
|
-
|
|
578
|
-
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:
|
|
579
|
-
|
|
580
|
-
```js
|
|
581
|
-
{
|
|
582
|
-
"name": "permissions",
|
|
583
|
-
"description": "Get or edit permissions for a user or a role",
|
|
584
|
-
"options": [
|
|
585
|
-
{
|
|
586
|
-
"name": "user",
|
|
587
|
-
"description": "Get or edit permissions for a user",
|
|
588
|
-
"type": 2, // 2 is type SUB_COMMAND_GROUP
|
|
589
|
-
"options": [
|
|
590
|
-
{
|
|
591
|
-
"name": "get",
|
|
592
|
-
"description": "Get permissions for a user",
|
|
593
|
-
"type": 1, // 1 is type SUB_COMMAND
|
|
594
|
-
"options": [
|
|
595
|
-
{
|
|
596
|
-
"name": "user",
|
|
597
|
-
"description": "The user to get",
|
|
598
|
-
"type": 6, // 6 is type USER
|
|
599
|
-
"required": true
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
"name": "channel",
|
|
603
|
-
"description": "The channel permissions to get. If omitted, the guild permissions will be returned",
|
|
604
|
-
"type": 7, // 7 is type CHANNEL
|
|
605
|
-
"required": false
|
|
606
|
-
}
|
|
607
|
-
]
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
"name": "edit",
|
|
611
|
-
"description": "Edit permissions for a user",
|
|
612
|
-
"type": 1,
|
|
613
|
-
"options": [
|
|
614
|
-
{
|
|
615
|
-
"name": "user",
|
|
616
|
-
"description": "The user to edit",
|
|
617
|
-
"type": 6,
|
|
618
|
-
"required": true
|
|
619
|
-
},
|
|
620
|
-
{
|
|
621
|
-
"name": "channel",
|
|
622
|
-
"description": "The channel permissions to edit. If omitted, the guild permissions will be edited",
|
|
623
|
-
"type": 7,
|
|
624
|
-
"required": false
|
|
625
|
-
}
|
|
626
|
-
]
|
|
627
|
-
}
|
|
628
|
-
]
|
|
629
|
-
},
|
|
630
|
-
{
|
|
631
|
-
"name": "role",
|
|
632
|
-
"description": "Get or edit permissions for a role",
|
|
633
|
-
"type": 2,
|
|
634
|
-
"options": [
|
|
635
|
-
{
|
|
636
|
-
"name": "get",
|
|
637
|
-
"description": "Get permissions for a role",
|
|
638
|
-
"type": 1,
|
|
639
|
-
"options": [
|
|
640
|
-
{
|
|
641
|
-
"name": "role",
|
|
642
|
-
"description": "The role to get",
|
|
643
|
-
"type": 8, // 8 is type ROLE
|
|
644
|
-
"required": true
|
|
645
|
-
},
|
|
646
|
-
{
|
|
647
|
-
"name": "channel",
|
|
648
|
-
"description": "The channel permissions to get. If omitted, the guild permissions will be returned",
|
|
649
|
-
"type": 7,
|
|
650
|
-
"required": false
|
|
651
|
-
}
|
|
652
|
-
]
|
|
653
|
-
},
|
|
654
|
-
{
|
|
655
|
-
"name": "edit",
|
|
656
|
-
"description": "Edit permissions for a role",
|
|
657
|
-
"type": 1,
|
|
658
|
-
"options": [
|
|
659
|
-
{
|
|
660
|
-
"name": "role",
|
|
661
|
-
"description": "The role to edit",
|
|
662
|
-
"type": 8,
|
|
663
|
-
"required": true
|
|
664
|
-
},
|
|
665
|
-
{
|
|
666
|
-
"name": "channel",
|
|
667
|
-
"description": "The channel permissions to edit. If omitted, the guild permissions will be edited",
|
|
668
|
-
"type": 7,
|
|
669
|
-
"required": false
|
|
670
|
-
}
|
|
671
|
-
]
|
|
672
|
-
}
|
|
673
|
-
]
|
|
674
|
-
}
|
|
675
|
-
]
|
|
676
|
-
}
|
|
677
|
-
```
|
|
678
|
-
|
|
679
|
-
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. Here's what it looks like all put together.
|
|
680
|
-
|
|
681
|
-

|
|
682
|
-
|
|
683
|
-
## User Commands
|
|
684
|
-
|
|
685
|
-
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.
|
|
686
|
-
|
|
687
|
-
> warn
|
|
688
|
-
> A user must have permission to send text messages in the channel they invoke a user command in. If they don't have this permission, they will receive a 'Permission Denied' error from the interaction.
|
|
689
|
-
|
|
690
|
-
> danger
|
|
691
|
-
> The `description` field is not allowed when creating user commands. However, to avoid breaking changes to data models, `description` will be an **empty string** (instead of `null`) when fetching commands.
|
|
692
|
-
|
|
693
|
-
###### Example User Command
|
|
694
|
-
|
|
695
|
-
```json
|
|
696
|
-
{
|
|
697
|
-
"name": "High Five",
|
|
698
|
-
"type": 2
|
|
699
|
-
}
|
|
700
|
-
```
|
|
701
|
-
|
|
702
|
-

|
|
703
|
-
|
|
704
|
-
When someone uses a user command, your application will receive an interaction:
|
|
705
|
-
|
|
706
|
-
###### Example Interaction
|
|
707
|
-
|
|
708
|
-
```json
|
|
709
|
-
{
|
|
710
|
-
"application_id": "775799577604522054",
|
|
711
|
-
"channel_id": "772908445358620702",
|
|
712
|
-
"data": {
|
|
713
|
-
"id": "866818195033292850",
|
|
714
|
-
"name": "context-menu-user-2",
|
|
715
|
-
"resolved": {
|
|
716
|
-
"members": {
|
|
717
|
-
"809850198683418695": {
|
|
718
|
-
"avatar": null,
|
|
719
|
-
"is_pending": false,
|
|
720
|
-
"joined_at": "2021-02-12T18:25:07.972000+00:00",
|
|
721
|
-
"nick": null,
|
|
722
|
-
"pending": false,
|
|
723
|
-
"permissions": "246997699136",
|
|
724
|
-
"premium_since": null,
|
|
725
|
-
"roles": []
|
|
726
|
-
}
|
|
727
|
-
},
|
|
728
|
-
"users": {
|
|
729
|
-
"809850198683418695": {
|
|
730
|
-
"avatar": "afc428077119df8aabbbd84b0dc90c74",
|
|
731
|
-
"bot": true,
|
|
732
|
-
"discriminator": "7302",
|
|
733
|
-
"id": "809850198683418695",
|
|
734
|
-
"public_flags": 0,
|
|
735
|
-
"username": "VoltyDemo"
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
},
|
|
739
|
-
"target_id": "809850198683418695",
|
|
740
|
-
"type": 2
|
|
741
|
-
},
|
|
742
|
-
"guild_id": "772904309264089089",
|
|
743
|
-
"id": "867794291820986368",
|
|
744
|
-
"member": {
|
|
745
|
-
"avatar": null,
|
|
746
|
-
"deaf": false,
|
|
747
|
-
"is_pending": false,
|
|
748
|
-
"joined_at": "2020-11-02T20:46:57.364000+00:00",
|
|
749
|
-
"mute": false,
|
|
750
|
-
"nick": null,
|
|
751
|
-
"pending": false,
|
|
752
|
-
"permissions": "274877906943",
|
|
753
|
-
"premium_since": null,
|
|
754
|
-
"roles": ["785609923542777878"],
|
|
755
|
-
"user": {
|
|
756
|
-
"avatar": "a_f03401914fb4f3caa9037578ab980920",
|
|
757
|
-
"discriminator": "6538",
|
|
758
|
-
"id": "167348773423415296",
|
|
759
|
-
"public_flags": 1,
|
|
760
|
-
"username": "ian"
|
|
761
|
-
}
|
|
762
|
-
},
|
|
763
|
-
"token": "UNIQUE_TOKEN",
|
|
764
|
-
"type": 2,
|
|
765
|
-
"version": 1
|
|
766
|
-
}
|
|
767
|
-
```
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
## Message Commands
|
|
771
|
-
|
|
772
|
-
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.
|
|
773
|
-
|
|
774
|
-
> danger
|
|
775
|
-
> The `description` field is not allowed when creating message commands. However, to avoid breaking changes to data models, `description` will be an **empty string** (instead of `null`) when fetching commands.
|
|
776
|
-
|
|
777
|
-
###### Example Message Command
|
|
778
|
-
|
|
779
|
-
```json
|
|
780
|
-
{
|
|
781
|
-
"name": "Bookmark",
|
|
782
|
-
"type": 3
|
|
783
|
-
}
|
|
784
|
-
```
|
|
785
|
-
|
|
786
|
-

|
|
787
|
-
|
|
788
|
-
When someone uses a message command, your application will receive an interaction:
|
|
789
|
-
|
|
790
|
-
###### Example Interaction
|
|
791
|
-
|
|
792
|
-
```json
|
|
793
|
-
{
|
|
794
|
-
"application_id": "775799577604522054",
|
|
795
|
-
"channel_id": "772908445358620702",
|
|
796
|
-
"data": {
|
|
797
|
-
"id": "866818195033292851",
|
|
798
|
-
"name": "context-menu-message-2",
|
|
799
|
-
"resolved": {
|
|
800
|
-
"messages": {
|
|
801
|
-
"867793854505943041": {
|
|
802
|
-
"attachments": [],
|
|
803
|
-
"author": {
|
|
804
|
-
"avatar": "a_f03401914fb4f3caa9037578ab980920",
|
|
805
|
-
"discriminator": "6538",
|
|
806
|
-
"id": "167348773423415296",
|
|
807
|
-
"public_flags": 1,
|
|
808
|
-
"username": "ian"
|
|
809
|
-
},
|
|
810
|
-
"channel_id": "772908445358620702",
|
|
811
|
-
"components": [],
|
|
812
|
-
"content": "some message",
|
|
813
|
-
"edited_timestamp": null,
|
|
814
|
-
"embeds": [],
|
|
815
|
-
"flags": 0,
|
|
816
|
-
"id": "867793854505943041",
|
|
817
|
-
"mention_everyone": false,
|
|
818
|
-
"mention_roles": [],
|
|
819
|
-
"mentions": [],
|
|
820
|
-
"pinned": false,
|
|
821
|
-
"timestamp": "2021-07-22T15:42:57.744000+00:00",
|
|
822
|
-
"tts": false,
|
|
823
|
-
"type": 0
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
},
|
|
827
|
-
"target_id": "867793854505943041",
|
|
828
|
-
"type": 3
|
|
829
|
-
},
|
|
830
|
-
"guild_id": "772904309264089089",
|
|
831
|
-
"id": "867793873336926249",
|
|
832
|
-
"member": {
|
|
833
|
-
"avatar": null,
|
|
834
|
-
"deaf": false,
|
|
835
|
-
"is_pending": false,
|
|
836
|
-
"joined_at": "2020-11-02T20:46:57.364000+00:00",
|
|
837
|
-
"mute": false,
|
|
838
|
-
"nick": null,
|
|
839
|
-
"pending": false,
|
|
840
|
-
"permissions": "274877906943",
|
|
841
|
-
"premium_since": null,
|
|
842
|
-
"roles": ["785609923542777878"],
|
|
843
|
-
"user": {
|
|
844
|
-
"avatar": "a_f03401914fb4f3caa9037578ab980920",
|
|
845
|
-
"discriminator": "6538",
|
|
846
|
-
"id": "167348773423415296",
|
|
847
|
-
"public_flags": 1,
|
|
848
|
-
"username": "ian"
|
|
849
|
-
}
|
|
850
|
-
},
|
|
851
|
-
"token": "UNIQUE_TOKEN",
|
|
852
|
-
"type": 2,
|
|
853
|
-
"version": 1
|
|
854
|
-
}
|
|
855
|
-
```
|
|
856
|
-
|
|
857
|
-
## Autocomplete
|
|
858
|
-
|
|
859
|
-
Autocomplete interactions allow your application to dynamically return option suggestions to a user as they type.
|
|
860
|
-
|
|
861
|
-
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.
|
|
862
|
-
|
|
863
|
-
> warn
|
|
864
|
-
> This validation is **client-side only**.
|
|
865
|
-
|
|
866
|
-
```json
|
|
867
|
-
{
|
|
868
|
-
"type": 4,
|
|
869
|
-
"data": {
|
|
870
|
-
"id": "816437322781949972",
|
|
871
|
-
"name": "airhorn",
|
|
872
|
-
"type": 1,
|
|
873
|
-
"version": "847194950382780532",
|
|
874
|
-
"options": [
|
|
875
|
-
{
|
|
876
|
-
"type": 3,
|
|
877
|
-
"name": "variant",
|
|
878
|
-
"value": "data a user is typ",
|
|
879
|
-
"focused": true
|
|
880
|
-
}
|
|
881
|
-
]
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
```
|
|
885
|
-
|
|
886
|
-
### Endpoints
|
|
887
|
-
|
|
888
|
-
> info
|
|
889
|
-
> For authorization, all endpoints take either a [bot token](#DOCS_REFERENCE/authentication) or [client credentials token](#DOCS_TOPICS_OAUTH2/client-credentials-grant) for your application
|
|
890
|
-
|
|
891
|
-
## Get Global Application Commands % GET /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/commands
|
|
892
|
-
|
|
893
|
-
Fetch all of the global commands for your application. Returns an array of [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) objects.
|
|
894
|
-
|
|
895
|
-
## Create Global Application Command % POST /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/commands
|
|
896
|
-
|
|
897
|
-
> danger
|
|
898
|
-
> Creating a command with the same name as an existing command for your application will overwrite the old command.
|
|
899
|
-
|
|
900
|
-
Create a new global command. New global commands will be available in all guilds after 1 hour. Returns `201` and an [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) object.
|
|
901
|
-
|
|
902
|
-
###### JSON Params
|
|
903
|
-
|
|
904
|
-
| Field | Type | Description |
|
|
905
|
-
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
906
|
-
| name | string | [1-32 character name](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-naming) |
|
|
907
|
-
| description | string | 1-100 character description |
|
|
908
|
-
| options? | array of [application command option](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-structure) | the parameters for the command |
|
|
909
|
-
| default_permission? | boolean (default `true`) | whether the command is enabled by default when the app is added to a guild |
|
|
910
|
-
| type? | one of [application command type](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-types) | the type of command, defaults `1` if not set |
|
|
911
|
-
|
|
912
|
-
## Get Global Application Command % GET /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/commands/{command.id#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object}
|
|
913
|
-
|
|
914
|
-
Fetch a global command for your application. Returns an [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) object.
|
|
915
|
-
|
|
916
|
-
## Edit Global Application Command % PATCH /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/commands/{command.id#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object}
|
|
917
|
-
|
|
918
|
-
> info
|
|
919
|
-
> All parameters for this endpoint are optional.
|
|
920
|
-
|
|
921
|
-
Edit a global command. Updates will be available in all guilds after 1 hour. Returns `200` and an [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) object.
|
|
922
|
-
|
|
923
|
-
###### JSON Params
|
|
924
|
-
|
|
925
|
-
| Field | Type | Description |
|
|
926
|
-
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
927
|
-
| name? | string | [1-32 character name](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-naming) |
|
|
928
|
-
| description? | string | 1-100 character description |
|
|
929
|
-
| options? | array of [application command option](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-structure) | the parameters for the command |
|
|
930
|
-
| default_permission? | boolean (default `true`) | whether the command is enabled by default when the app is added to a guild |
|
|
931
|
-
|
|
932
|
-
## Delete Global Application Command % DELETE /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/commands/{command.id#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object}
|
|
933
|
-
|
|
934
|
-
Deletes a global command. Returns `204 No Content` on success.
|
|
935
|
-
|
|
936
|
-
## Bulk Overwrite Global Application Commands % PUT /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/commands
|
|
937
|
-
|
|
938
|
-
Takes a list of application commands, overwriting the existing global command list for this application. Updates will be available in all guilds after 1 hour. Returns `200` and a list of [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) objects. Commands that do not already exist will count toward daily application command create limits.
|
|
939
|
-
|
|
940
|
-
> danger
|
|
941
|
-
> This will overwrite **all** types of application commands: slash commands, user commands, and message commands.
|
|
942
|
-
|
|
943
|
-
## Get Guild Application Commands % GET /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands
|
|
944
|
-
|
|
945
|
-
Fetch all of the guild commands for your application for a specific guild. Returns an array of [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) objects.
|
|
946
|
-
|
|
947
|
-
## Create Guild Application Command % POST /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands
|
|
948
|
-
|
|
949
|
-
> danger
|
|
950
|
-
> Creating a command with the same name as an existing command for your application will overwrite the old command.
|
|
951
|
-
|
|
952
|
-
Create a new guild command. New guild commands will be available in the guild immediately. Returns `201` and an [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) object. If the command did not already exist, it will count toward daily application command create limits.
|
|
953
|
-
|
|
954
|
-
###### JSON Params
|
|
955
|
-
|
|
956
|
-
| Field | Type | Description |
|
|
957
|
-
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
958
|
-
| name | string | [1-32 character name](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-naming) |
|
|
959
|
-
| description | string | 1-100 character description |
|
|
960
|
-
| options? | array of [application command option](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-structure) | the parameters for the command |
|
|
961
|
-
| default_permission? | boolean (default `true`) | whether the command is enabled by default when the app is added to a guild |
|
|
962
|
-
| type? | one of [application command type](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-types) | the type of command, defaults `1` if not set |
|
|
963
|
-
|
|
964
|
-
## Get Guild Application Command % GET /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands/{command.id#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object}
|
|
965
|
-
|
|
966
|
-
Fetch a guild command for your application. Returns an [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) object.
|
|
967
|
-
|
|
968
|
-
## Edit Guild Application Command % PATCH /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands/{command.id#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object}
|
|
969
|
-
|
|
970
|
-
> info
|
|
971
|
-
> All parameters for this endpoint are optional.
|
|
972
|
-
|
|
973
|
-
Edit a guild command. Updates for guild commands will be available immediately. Returns `200` and an [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) object.
|
|
974
|
-
|
|
975
|
-
###### JSON Params
|
|
976
|
-
|
|
977
|
-
| Field | Type | Description |
|
|
978
|
-
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
979
|
-
| name? | string | [1-32 character name](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-naming) |
|
|
980
|
-
| description? | string | 1-100 character description |
|
|
981
|
-
| options? | array of [application command option](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-structure) | the parameters for the command |
|
|
982
|
-
| default_permission? | boolean (default `true`) | whether the command is enabled by default when the app is added to a guild |
|
|
983
|
-
|
|
984
|
-
## Delete Guild Application Command % DELETE /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands/{command.id#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object}
|
|
985
|
-
|
|
986
|
-
Delete a guild command. Returns `204 No Content` on success.
|
|
987
|
-
|
|
988
|
-
## Bulk Overwrite Guild Application Commands % PUT /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands
|
|
989
|
-
|
|
990
|
-
Takes a list of application commands, overwriting the existing command list for this application for the targeted guild. Returns `200` and a list of [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object) objects.
|
|
991
|
-
|
|
992
|
-
> danger
|
|
993
|
-
> This will overwrite **all** types of application commands: slash commands, user commands, and message commands.
|
|
994
|
-
|
|
995
|
-
## Get Guild Application Command Permissions % GET /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands/permissions
|
|
996
|
-
|
|
997
|
-
Fetches command permissions for all commands for your application in a guild. Returns an array of [guild application command permissions](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-permissions-object-guild-application-command-permissions-structure) objects.
|
|
998
|
-
|
|
999
|
-
## Get Application Command Permissions % GET /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands/{command.id#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object}/permissions
|
|
1000
|
-
|
|
1001
|
-
Fetches command permissions for a specific command for your application in a guild. Returns a [guild application command permissions](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-permissions-object-guild-application-command-permissions-structure) object.
|
|
1002
|
-
|
|
1003
|
-
## Edit Application Command Permissions % PUT /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands/{command.id#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object}/permissions
|
|
1004
|
-
|
|
1005
|
-
> warn
|
|
1006
|
-
> This endpoint will overwrite existing permissions for the command in that guild
|
|
1007
|
-
|
|
1008
|
-
Edits command permissions for a specific command for your application in a guild.
|
|
1009
|
-
You can only add up to 10 permission overwrites for a command.
|
|
1010
|
-
Returns a [GuildApplicationCommandPermissions](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-permissions-object-guild-application-command-permissions-structure) object.
|
|
1011
|
-
|
|
1012
|
-
> warn
|
|
1013
|
-
> Deleting or renaming a command will permanently delete all permissions for that command
|
|
1014
|
-
|
|
1015
|
-
###### JSON Params
|
|
1016
|
-
|
|
1017
|
-
| Field | Type | Description |
|
|
1018
|
-
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
|
|
1019
|
-
| permissions | array of [application command permissions](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-permissions-object-application-command-permissions-structure) | the permissions for the command in the guild |
|
|
1020
|
-
|
|
1021
|
-
## Batch Edit Application Command Permissions % PUT /applications/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/guilds/{guild.id#DOCS_RESOURCES_GUILD/guild-object}/commands/permissions
|
|
1022
|
-
|
|
1023
|
-
> warn
|
|
1024
|
-
> This endpoint will overwrite all existing permissions for all commands in a guild, including slash commands, user commands, and message commands.
|
|
1025
|
-
|
|
1026
|
-
Batch edits permissions for all commands in a guild. Takes an array of partial [guild application command permissions](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-permissions-object-guild-application-command-permissions-structure) objects including `id` and `permissions`.
|
|
1027
|
-
|
|
1028
|
-
You can only add up to 10 permission overwrites for a command.
|
|
1029
|
-
|
|
1030
|
-
Returns an array of [GuildApplicationCommandPermissions](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-permissions-object-guild-application-command-permissions-structure) objects.
|
|
1031
|
-
|
|
1032
|
-
###### Example
|
|
1033
|
-
|
|
1034
|
-
```py
|
|
1035
|
-
FIRST_COMMAND_ID = "<first_command_id>"
|
|
1036
|
-
SECOND_COMMAND_ID = "<second_command_id>"
|
|
1037
|
-
ADMIN_ROLE_ID = "<admin_role_id>"
|
|
1038
|
-
|
|
1039
|
-
url = "https://discord.com/api/v8/applications/<my_application_id>/guilds/<my_guild_id>/commands/permissions"
|
|
1040
|
-
|
|
1041
|
-
json = [
|
|
1042
|
-
{
|
|
1043
|
-
"id": FIRST_COMMAND_ID,
|
|
1044
|
-
"permissions": [
|
|
1045
|
-
{
|
|
1046
|
-
"id": ADMIN_ROLE_ID,
|
|
1047
|
-
"type": 1,
|
|
1048
|
-
"permission": True
|
|
1049
|
-
}
|
|
1050
|
-
]
|
|
1051
|
-
},
|
|
1052
|
-
{
|
|
1053
|
-
"id": SECOND_COMMAND_ID,
|
|
1054
|
-
"permissions": [
|
|
1055
|
-
{
|
|
1056
|
-
"id": ADMIN_ROLE_ID,
|
|
1057
|
-
"type": 1,
|
|
1058
|
-
"permission": False
|
|
1059
|
-
}
|
|
1060
|
-
]
|
|
1061
|
-
}
|
|
1062
|
-
]
|
|
1063
|
-
|
|
1064
|
-
headers = {
|
|
1065
|
-
"Authorization": "Bot <my_bot_token>"
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
r = requests.put(url, headers=headers, json=json)
|
|
1069
|
-
```
|