dfx 0.0.1
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/.gitmodules +3 -0
- package/.prettierrc.json +4 -0
- package/DiscordREST/types.ts +5 -0
- package/DiscordWS/index.ts +0 -0
- package/WS/index.ts +122 -0
- package/discord-api-docs/.eslintrc.json +10 -0
- package/discord-api-docs/.gitattributes +11 -0
- package/discord-api-docs/.github/ISSUE_TEMPLATE/api-bug-report.yml +49 -0
- package/discord-api-docs/.github/ISSUE_TEMPLATE/config.yml +20 -0
- package/discord-api-docs/.github/ISSUE_TEMPLATE/developer-site-bug-report.yml +49 -0
- package/discord-api-docs/.github/ISSUE_TEMPLATE/message-components-bug-report.yml +49 -0
- package/discord-api-docs/.github/ISSUE_TEMPLATE/slash-command-bug-report.yml +49 -0
- package/discord-api-docs/.github/workflows/test.yaml +45 -0
- package/discord-api-docs/.prettierignore +1 -0
- package/discord-api-docs/.prettierrc.json +15 -0
- package/discord-api-docs/CODE_OF_CONDUCT.md +75 -0
- package/discord-api-docs/CONTRIBUTING.md +16 -0
- package/discord-api-docs/README.md +35 -0
- package/discord-api-docs/ci/checkLinks.ts +177 -0
- package/discord-api-docs/docs/Change_Log.md +474 -0
- package/discord-api-docs/docs/Intro.md +48 -0
- package/discord-api-docs/docs/Legal.md +154 -0
- package/discord-api-docs/docs/Policy.md +81 -0
- package/discord-api-docs/docs/Reference.md +476 -0
- package/discord-api-docs/docs/Store_Distribution_Agreement.md +179 -0
- package/discord-api-docs/docs/dispatch/Branches_and_Builds.md +654 -0
- package/discord-api-docs/docs/dispatch/Dispatch_and_You.md +17 -0
- package/discord-api-docs/docs/dispatch/Error_Codes.md +26 -0
- package/discord-api-docs/docs/dispatch/Field_Values.md +48 -0
- package/discord-api-docs/docs/dispatch/List_of_Commands.md +315 -0
- package/discord-api-docs/docs/game_and_server_management/Alpha_and_Beta_Testing.md +52 -0
- package/discord-api-docs/docs/game_and_server_management/How_to_Get_Your_Game_on_Discord.md +110 -0
- package/discord-api-docs/docs/game_and_server_management/Special_Channels.md +38 -0
- package/discord-api-docs/docs/game_sdk/Achievements.md +405 -0
- package/discord-api-docs/docs/game_sdk/Activities.md +561 -0
- package/discord-api-docs/docs/game_sdk/Applications.md +237 -0
- package/discord-api-docs/docs/game_sdk/Discord.md +443 -0
- package/discord-api-docs/docs/game_sdk/Discord_Voice.md +289 -0
- package/discord-api-docs/docs/game_sdk/Images.md +196 -0
- package/discord-api-docs/docs/game_sdk/Lobbies.md +1639 -0
- package/discord-api-docs/docs/game_sdk/Networking.md +377 -0
- package/discord-api-docs/docs/game_sdk/Overlay.md +195 -0
- package/discord-api-docs/docs/game_sdk/Relationships.md +234 -0
- package/discord-api-docs/docs/game_sdk/SDK_Starter_Guide.md +310 -0
- package/discord-api-docs/docs/game_sdk/Storage.md +312 -0
- package/discord-api-docs/docs/game_sdk/Store.md +555 -0
- package/discord-api-docs/docs/game_sdk/Users.md +178 -0
- package/discord-api-docs/docs/interactions/Application_Commands.md +1069 -0
- package/discord-api-docs/docs/interactions/Message_Components.md +454 -0
- package/discord-api-docs/docs/interactions/Receiving_and_Responding.md +372 -0
- package/discord-api-docs/docs/interactions/Slash_Commands.md +3 -0
- package/discord-api-docs/docs/resources/Application.md +82 -0
- package/discord-api-docs/docs/resources/Audit_Log.md +223 -0
- package/discord-api-docs/docs/resources/Channel.md +1267 -0
- package/discord-api-docs/docs/resources/Emoji.md +122 -0
- package/discord-api-docs/docs/resources/Guild.md +1157 -0
- package/discord-api-docs/docs/resources/Guild_Scheduled_Event.md +273 -0
- package/discord-api-docs/docs/resources/Guild_Template.md +148 -0
- package/discord-api-docs/docs/resources/Invite.md +150 -0
- package/discord-api-docs/docs/resources/Stage_Instance.md +106 -0
- package/discord-api-docs/docs/resources/Sticker.md +164 -0
- package/discord-api-docs/docs/resources/User.md +205 -0
- package/discord-api-docs/docs/resources/Voice.md +55 -0
- package/discord-api-docs/docs/resources/Webhook.md +281 -0
- package/discord-api-docs/docs/rich_presence/Best_Practices.md +88 -0
- package/discord-api-docs/docs/rich_presence/FAQ.md +45 -0
- package/discord-api-docs/docs/rich_presence/How_To.md +302 -0
- package/discord-api-docs/docs/rich_presence/Launch_Checklist.md +46 -0
- package/discord-api-docs/docs/topics/Certified_Devices.md +200 -0
- package/discord-api-docs/docs/topics/Community_Resources.md +98 -0
- package/discord-api-docs/docs/topics/Gateway.md +1600 -0
- package/discord-api-docs/docs/topics/OAuth2.md +427 -0
- package/discord-api-docs/docs/topics/Opcodes_and_Status_Codes.md +306 -0
- package/discord-api-docs/docs/topics/Permissions.md +229 -0
- package/discord-api-docs/docs/topics/RPC.md +1597 -0
- package/discord-api-docs/docs/topics/Rate_Limits.md +126 -0
- package/discord-api-docs/docs/topics/Teams.md +80 -0
- package/discord-api-docs/docs/topics/Threads.md +163 -0
- package/discord-api-docs/docs/topics/Voice_Connections.md +282 -0
- 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 +3186 -0
- package/discord-api-docs/package.json +38 -0
- package/discord-api-docs/tsconfig.eslint.json +4 -0
- package/discord-api-docs/tsconfig.json +19 -0
- package/mod.js +14 -0
- package/mod.ts +24 -0
- package/package.json +28 -0
- package/tsconfig.json +24 -0
- package/types.ts +5334 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
# Interactions
|
|
2
|
+
|
|
3
|
+
An **[Interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object)** is the message that your application receives when a user uses an application command or a message component.
|
|
4
|
+
|
|
5
|
+
For [Slash Commands](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/slash-commands), it includes the values that the user submitted.
|
|
6
|
+
|
|
7
|
+
For [User Commands](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/user-commands) and [Message Commands](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/message-commands), it includes the resolved user or message on which the action was taken.
|
|
8
|
+
|
|
9
|
+
For [Message Components](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/) it includes identifying information about the component that was used. It will also include some metadata about how the interaction was triggered: the `guild_id`, `channel_id`, `member` and other fields. You can find all the values in our data models below.
|
|
10
|
+
|
|
11
|
+
### Interaction Object
|
|
12
|
+
|
|
13
|
+
###### Interaction Structure
|
|
14
|
+
|
|
15
|
+
| Field | Type | Description |
|
|
16
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
17
|
+
| id | snowflake | id of the interaction |
|
|
18
|
+
| application_id | snowflake | id of the application this interaction is for |
|
|
19
|
+
| type | [interaction type](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object-interaction-type) | the type of interaction |
|
|
20
|
+
| data?\* | [interaction data](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object-interaction-data-structure) | the command data payload |
|
|
21
|
+
| guild_id? | snowflake | the guild it was sent from |
|
|
22
|
+
| channel_id? | snowflake | the channel it was sent from |
|
|
23
|
+
| member?\*\* | [guild member](#DOCS_RESOURCES_GUILD/guild-member-object) object | guild member data for the invoking user, including permissions |
|
|
24
|
+
| user? | [user](#DOCS_RESOURCES_USER/user-object) object | user object for the invoking user, if invoked in a DM |
|
|
25
|
+
| token | string | a continuation token for responding to the interaction |
|
|
26
|
+
| version | integer | read-only property, always `1` |
|
|
27
|
+
| message? | [message](#DOCS_RESOURCES_CHANNEL/message-object) object | for components, the message they were attached to |
|
|
28
|
+
| locale?\*\*\* | string | the selected [language](#DOCS_REFERENCE/locales) of the invoking user |
|
|
29
|
+
| guild_locale? | string | the [guild's preferred locale](#DOCS_RESOURCES_GUILD/guild-object), if invoked in a guild |
|
|
30
|
+
|
|
31
|
+
\* This is always present on application command, message component, and modal submit interaction types. It is optional for future-proofing against new interaction types
|
|
32
|
+
|
|
33
|
+
\*\* `member` is sent when the interaction is invoked in a guild, and `user` is sent when invoked in a DM
|
|
34
|
+
|
|
35
|
+
\*\*\* This is available on all interaction types except PING
|
|
36
|
+
|
|
37
|
+
###### Interaction Type
|
|
38
|
+
|
|
39
|
+
| Name | Value |
|
|
40
|
+
| -------------------------------- | ----- |
|
|
41
|
+
| PING | 1 |
|
|
42
|
+
| APPLICATION_COMMAND | 2 |
|
|
43
|
+
| MESSAGE_COMPONENT | 3 |
|
|
44
|
+
| APPLICATION_COMMAND_AUTOCOMPLETE | 4 |
|
|
45
|
+
| MODAL_SUBMIT | 5 |
|
|
46
|
+
|
|
47
|
+
###### Interaction Data Structure
|
|
48
|
+
|
|
49
|
+
| Field | Type | Description | Interaction Type |
|
|
50
|
+
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
51
|
+
| id | snowflake | the [`ID`](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-structure) of the invoked command | Application Command |
|
|
52
|
+
| name | string | the [`name`](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-structure) of the invoked command | Application Command |
|
|
53
|
+
| type | integer | the [`type`](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-structure) of the invoked command | Application Command |
|
|
54
|
+
| resolved? | [resolved data](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object-resolved-data-structure) | converted users + roles + channels + attachments | Application Command |
|
|
55
|
+
| options? | array of [application command interaction data option](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-interaction-data-option-structure) | the params + values from the user | Application Command |
|
|
56
|
+
| custom_id? | string | the [`custom_id`](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/custom-id) of the component | Component, Modal Submit |
|
|
57
|
+
| component_type? | integer | the [type](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/component-object-component-types) of the component | Component |
|
|
58
|
+
| values? | array of [select option values](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/select-menu-object-select-option-structure) | the values the user selected | Component (Select) |
|
|
59
|
+
| target_id? | snowflake | id the of user or message targeted by a [user](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/user-commands) or [message](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/message-commands) command | [User Command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/user-commands), [Message Command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/message-commands) |
|
|
60
|
+
| components? | array of [message components](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/message-components) | the values submitted by the user | Modal Submit |
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
###### Resolved Data Structure
|
|
64
|
+
|
|
65
|
+
> info
|
|
66
|
+
> If data for a Member is included, data for its corresponding User will also be included.
|
|
67
|
+
|
|
68
|
+
| Field | Type | Description |
|
|
69
|
+
| ------------- | ---------------------------------------------------------------------------------------- | ----------------------------------- |
|
|
70
|
+
| users? | Map of Snowflakes to [user](#DOCS_RESOURCES_USER/user-object) objects | the ids and User objects |
|
|
71
|
+
| members?\* | Map of Snowflakes to [partial member](#DOCS_RESOURCES_GUILD/guild-member-object) objects | the ids and partial Member objects |
|
|
72
|
+
| roles? | Map of Snowflakes to [role](#DOCS_TOPICS_PERMISSIONS/role-object) objects | the ids and Role objects |
|
|
73
|
+
| channels?\*\* | Map of Snowflakes to [partial channel](#DOCS_RESOURCES_CHANNEL/channel-object) objects | the ids and partial Channel objects |
|
|
74
|
+
| messages? | Map of Snowflakes to [partial messages](#DOCS_RESOURCES_CHANNEL/message-object) objects | the ids and partial Message objects |
|
|
75
|
+
| attachments? | Map of Snowflakes to [attachment](#DOCS_RESOURCES_CHANNEL/attachment-object) objects | the ids and attachment objects |
|
|
76
|
+
|
|
77
|
+
\* Partial `Member` objects are missing `user`, `deaf` and `mute` fields
|
|
78
|
+
|
|
79
|
+
\*\* Partial `Channel` objects only have `id`, `name`, `type` and `permissions` fields. Threads will also have `thread_metadata` and `parent_id` fields.
|
|
80
|
+
|
|
81
|
+
### Message Interaction Object
|
|
82
|
+
|
|
83
|
+
This is sent on the [message object](#DOCS_RESOURCES_CHANNEL/message-object) when the message is a response to an Interaction without an existing message.
|
|
84
|
+
|
|
85
|
+
> info
|
|
86
|
+
> This means responses to [Message Components](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/) do not include this property, instead including a [message reference](#DOCS_RESOURCES_CHANNEL/message-reference-object-message-reference-structure) object as components _always_ exist on preexisting messages.
|
|
87
|
+
|
|
88
|
+
###### Message Interaction Structure
|
|
89
|
+
|
|
90
|
+
| Name | Type | Description |
|
|
91
|
+
| ---- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| id | snowflake | id of the interaction |
|
|
93
|
+
| type | [interaction type](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object-interaction-type) | the type of interaction |
|
|
94
|
+
| name | string | the name of the [application command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-structure) |
|
|
95
|
+
| user | [user object](#DOCS_RESOURCES_USER/user-object) | the user who invoked the interaction |
|
|
96
|
+
| member? | [partial member](#DOCS_RESOURCES_GUILD/guild-member-object) object | the member who invoked the interaction in the guild |
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## Interactions and Bot Users
|
|
100
|
+
|
|
101
|
+
We're all used to the way that Discord bots have worked for a long time. You make an application in the Dev Portal, you add a bot user to it, and you copy the token. That token can be used to connect to the gateway and to make requests against our API.
|
|
102
|
+
|
|
103
|
+
Interactions bring something entirely new to the table: the ability to interact with an application _without needing a bot user in the guild_. As you read through this documentation, you'll see that bot tokens are only referenced as a helpful alternative to doing a client credentials auth flow. Responding to interactions does not require a bot token.
|
|
104
|
+
|
|
105
|
+
In many cases, you may still need a bot user. If you need to receive gateway events, or need to interact with other parts of our API (like fetching a guild, or a channel, or updating permissions on a user), those actions are all still tied to having a bot token. However, if you don't need any of those things, you never have to add a bot user to your application at all.
|
|
106
|
+
|
|
107
|
+
Welcome to the new world.
|
|
108
|
+
|
|
109
|
+
## Receiving an Interaction
|
|
110
|
+
|
|
111
|
+
When a user interacts with your app, your app will receive an **[Interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object)**. Your app can receive an interaction in one of two ways:
|
|
112
|
+
|
|
113
|
+
- Via [Interaction Create](#DOCS_TOPICS_GATEWAY/interaction-create) gateway event
|
|
114
|
+
- Via outgoing webhook
|
|
115
|
+
|
|
116
|
+
These two methods are **mutually exclusive**; you can _only_ receive Interactions one of the two ways. The `INTERACTION_CREATE` [Gateway Event](#DOCS_TOPICS_GATEWAY/interaction-create) may be handled by connected clients, while the webhook method detailed below does not require a connected client.
|
|
117
|
+
|
|
118
|
+
In your application in the Developer Portal, there is a field on the main page called "Interactions Endpoint URL". If you want to receive Interactions via outgoing webhook, you can set your URL in this field. In order for the URL to be valid, you must be prepared for two things ahead of time:
|
|
119
|
+
|
|
120
|
+
> info
|
|
121
|
+
> These steps are only necessary for webhook-based Interactions. It is not required for receiving them over the gateway.
|
|
122
|
+
|
|
123
|
+
1. Your endpoint must be prepared to ACK a `PING` message
|
|
124
|
+
2. Your endpoint must be set up to properly handle signature headers--more on that in [Security and Authorization](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/security-and-authorization)
|
|
125
|
+
|
|
126
|
+
If either of these are not complete, we will not validate your URL and it will fail to save.
|
|
127
|
+
|
|
128
|
+
When you attempt to save a URL, we will send a `POST` request to that URL with a `PING` payload. The `PING` payload has a `type: 1`. So, to properly ACK the payload, return a `200` response with a payload of `type: 1`:
|
|
129
|
+
|
|
130
|
+
```py
|
|
131
|
+
@app.route('/', methods=['POST'])
|
|
132
|
+
def my_command():
|
|
133
|
+
if request.json["type"] == 1:
|
|
134
|
+
return jsonify({
|
|
135
|
+
"type": 1
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
You'll also need to properly set up [Security and Authorization](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/security-and-authorization) on your endpoint for the URL to be accepted. Once both of those are complete and your URL has been saved, you can start receiving Interactions via webhook! At this point, your app will **no longer receive Interactions over the gateway**. If you want to receive them over the gateway again, simply delete your URL.
|
|
140
|
+
|
|
141
|
+
An [Interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object) includes metadata to aid your application in handling it as well as `data` specific to the interaction type. You can find samples for each interaction type on their respective pages:
|
|
142
|
+
|
|
143
|
+
- [Slash Commands](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/slash-commands-example-interaction)
|
|
144
|
+
- [User Commands](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/user-commands-example-interaction)
|
|
145
|
+
- [Message Commands](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/message-commands-example-interaction)
|
|
146
|
+
- [Message Components](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/component-interaction-object-sample-component-interaction)
|
|
147
|
+
- [Select Menu Message Components](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/select-menu-object-select-menu-interaction)
|
|
148
|
+
|
|
149
|
+
An explanation of all the fields can be found in our [data models](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object).
|
|
150
|
+
|
|
151
|
+
Now that you've gotten the data from the user, it's time to respond to them.
|
|
152
|
+
|
|
153
|
+
## Responding to an Interaction
|
|
154
|
+
|
|
155
|
+
Interactions--both receiving and responding--are webhooks under the hood. So responding to an Interaction is just like sending a webhook request!
|
|
156
|
+
|
|
157
|
+
There are a number of ways you can respond to an interaction:
|
|
158
|
+
|
|
159
|
+
### Interaction Response Object
|
|
160
|
+
|
|
161
|
+
###### Interaction Response Structure
|
|
162
|
+
|
|
163
|
+
| Field | Type | Description |
|
|
164
|
+
| ----- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
|
|
165
|
+
| type | [interaction callback type](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-response-object-interaction-callback-type) | the type of response |
|
|
166
|
+
| data? | [interaction callback data](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-response-object-interaction-callback-data-structure) | an optional response message |
|
|
167
|
+
|
|
168
|
+
###### Interaction Callback Type
|
|
169
|
+
|
|
170
|
+
| Name | Value | Description |
|
|
171
|
+
| --------------------------------------- | ----- | ------------------------------------------------------------------------------------------------------------- |
|
|
172
|
+
| PONG | 1 | ACK a `Ping` |
|
|
173
|
+
| CHANNEL_MESSAGE_WITH_SOURCE | 4 | respond to an interaction with a message |
|
|
174
|
+
| DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE | 5 | ACK an interaction and edit a response later, the user sees a loading state |
|
|
175
|
+
| DEFERRED_UPDATE_MESSAGE\* | 6 | for components, ACK an interaction and edit the original message later; the user does not see a loading state |
|
|
176
|
+
| UPDATE_MESSAGE\* | 7 | for components, edit the message the component was attached to |
|
|
177
|
+
| APPLICATION_COMMAND_AUTOCOMPLETE_RESULT | 8 | respond to an autocomplete interaction with suggested choices |
|
|
178
|
+
| MODAL\*\* | 9 | respond to an interaction with a popup modal |
|
|
179
|
+
|
|
180
|
+
\* Only valid for [component-based](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/) interactions
|
|
181
|
+
|
|
182
|
+
\*\* Not available for MODAL_SUBMIT and PING interactions.
|
|
183
|
+
|
|
184
|
+
###### Interaction Callback Data Structure
|
|
185
|
+
|
|
186
|
+
###### Messages
|
|
187
|
+
|
|
188
|
+
Not all message fields are currently supported.
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
| Name | Type | Description |
|
|
192
|
+
| ----------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
193
|
+
| tts? | boolean | is the response TTS |
|
|
194
|
+
| content? | string | message content |
|
|
195
|
+
| embeds? | array of [embeds](#DOCS_RESOURCES_CHANNEL/embed-object) | supports up to 10 embeds |
|
|
196
|
+
| allowed_mentions? | [allowed mentions](#DOCS_RESOURCES_CHANNEL/allowed-mentions-object) | [allowed mentions](#DOCS_RESOURCES_CHANNEL/allowed-mentions-object) object |
|
|
197
|
+
| flags? | integer | [message flags](#DOCS_RESOURCES_CHANNEL/message-object-message-flags) combined as a [bitfield](https://en.wikipedia.org/wiki/Bit_field) (only `SUPPRESS_EMBEDS` and `EPHEMERAL` can be set) |
|
|
198
|
+
| components? | array of [components](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/) | message components |
|
|
199
|
+
| attachments? \* | array of partial [attachment](#DOCS_RESOURCES_CHANNEL/attachment-object) objects | attachment objects with filename and description |
|
|
200
|
+
|
|
201
|
+
\* See [Uploading Files](#DOCS_REFERENCE/uploading-files) for details.
|
|
202
|
+
|
|
203
|
+
###### Autocomplete
|
|
204
|
+
|
|
205
|
+
| Name | Type | Description |
|
|
206
|
+
| -------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
|
|
207
|
+
| choices | array of [choices](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/application-command-object-application-command-option-choice-structure) | autocomplete choices (max of 25 choices) |
|
|
208
|
+
|
|
209
|
+
###### Modal
|
|
210
|
+
|
|
211
|
+
| Name | Type | Description |
|
|
212
|
+
| ---------- | ------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
|
213
|
+
| custom_id | string | a developer-defined identifier for the component, max 100 characters |
|
|
214
|
+
| title | string | the title of the popup modal |
|
|
215
|
+
| components | array of [components](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/) | between 1 and 5 (inclusive) components that make up the modal |
|
|
216
|
+
|
|
217
|
+
> warn
|
|
218
|
+
> While interaction responses and followups are webhooks, they respect @everyone's ability to ping @everyone / @here . Nonetheless if your application responds with user data, you should still use [`allowed_mentions`](#DOCS_RESOURCES_CHANNEL/allowed-mentions-object) to filter which mentions in the content actually ping. Other differences include the ability to send named links in the message content (`[text](url)`).
|
|
219
|
+
|
|
220
|
+
When responding to an interaction received **via webhook**, your server can simply respond to the received `POST` request. You'll want to respond with a `200` status code (if everything went well), as well as specifying a `type` and `data`, which is an [Interaction Response](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-response-object) object:
|
|
221
|
+
|
|
222
|
+
```py
|
|
223
|
+
@app.route('/', methods=['POST'])
|
|
224
|
+
def my_command():
|
|
225
|
+
if request.json["type"] == 1:
|
|
226
|
+
return jsonify({
|
|
227
|
+
"type": 1
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
else:
|
|
231
|
+
return jsonify({
|
|
232
|
+
"type": 4,
|
|
233
|
+
"data": {
|
|
234
|
+
"tts": False,
|
|
235
|
+
"content": "Congrats on sending your command!",
|
|
236
|
+
"embeds": [],
|
|
237
|
+
"allowed_mentions": { "parse": [] }
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
If you are receiving Interactions over the gateway, you will **also need to respond via HTTP**. Responses to Interactions **are not sent as commands over the gateway**.
|
|
243
|
+
|
|
244
|
+
To respond to a gateway Interaction, make a `POST` request like this. `interaction_id` is the unique id of that individual Interaction from the received payload. `interaction_token` is the unique token for that interaction from the received payload. **This endpoint is only valid for Interactions received over the gateway. Otherwise, respond to the `POST` request to issue an initial response.**
|
|
245
|
+
|
|
246
|
+
```py
|
|
247
|
+
import requests
|
|
248
|
+
|
|
249
|
+
url = "https://discord.com/api/v8/interactions/<interaction_id>/<interaction_token>/callback"
|
|
250
|
+
|
|
251
|
+
json = {
|
|
252
|
+
"type": 4,
|
|
253
|
+
"data": {
|
|
254
|
+
"content": "Congrats on sending your command!"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
r = requests.post(url, json=json)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
> info
|
|
261
|
+
> Interaction `tokens` are valid for **15 minutes** and can be used to send followup messages but you **must send an initial response within 3 seconds of receiving the event**. If the 3 second deadline is exceeded, the token will be invalidated.
|
|
262
|
+
|
|
263
|
+
## Followup Messages
|
|
264
|
+
|
|
265
|
+
Sometimes, your bot will want to send followup messages to a user after responding to an interaction. Or, you may want to edit your original response. Whether you receive Interactions over the gateway or by outgoing webhook, you can use the following endpoints to edit your initial response or send followup messages:
|
|
266
|
+
|
|
267
|
+
- [`PATCH /webhooks/<application_id>/<interaction_token>/messages/@original`](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/edit-original-interaction-response) to edit your initial response to an Interaction
|
|
268
|
+
- [`DELETE /webhooks/<application_id>/<interaction_token>/messages/@original`](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/delete-original-interaction-response) to delete your initial response to an Interaction
|
|
269
|
+
- [`POST /webhooks/<application_id>/<interaction_token>`](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/create-followup-message) to send a new followup message
|
|
270
|
+
- [`PATCH /webhooks/<application_id>/<interaction_token>/messages/<message_id>`](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/edit-followup-message) to edit a message sent with that `token`
|
|
271
|
+
|
|
272
|
+
> info
|
|
273
|
+
> Interactions webhooks share the same rate limit properties as normal webhooks.
|
|
274
|
+
|
|
275
|
+
Interaction tokens are valid for **15 minutes**, meaning you can respond to an interaction within that amount of time.
|
|
276
|
+
|
|
277
|
+
## Security and Authorization
|
|
278
|
+
|
|
279
|
+
> info
|
|
280
|
+
> Check out our [Community Resources](#DOCS_TOPICS_COMMUNITY_RESOURCES/interactions) for libraries to help you with security in your language of choice.
|
|
281
|
+
|
|
282
|
+
The internet is a scary place, especially for people hosting open, unauthenticated endpoints. If you are receiving Interactions via outgoing webhook, there are some security steps you **must** take before your app is eligible to receive requests.
|
|
283
|
+
|
|
284
|
+
Every Interaction is sent with the following headers:
|
|
285
|
+
|
|
286
|
+
- `X-Signature-Ed25519` as a signature
|
|
287
|
+
- `X-Signature-Timestamp` as a timestamp
|
|
288
|
+
|
|
289
|
+
Using your favorite security library, you **must validate the request each time you receive an [interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object)**. If the signature fails validation, respond with a `401` error code. Here's a couple code examples:
|
|
290
|
+
|
|
291
|
+
```js
|
|
292
|
+
const nacl = require('tweetnacl');
|
|
293
|
+
|
|
294
|
+
// Your public key can be found on your application in the Developer Portal
|
|
295
|
+
const PUBLIC_KEY = 'APPLICATION_PUBLIC_KEY';
|
|
296
|
+
|
|
297
|
+
const signature = req.get('X-Signature-Ed25519');
|
|
298
|
+
const timestamp = req.get('X-Signature-Timestamp');
|
|
299
|
+
const body = req.rawBody; // rawBody is expected to be a string, not raw bytes
|
|
300
|
+
|
|
301
|
+
const isVerified = nacl.sign.detached.verify(
|
|
302
|
+
Buffer.from(timestamp + body),
|
|
303
|
+
Buffer.from(signature, 'hex'),
|
|
304
|
+
Buffer.from(PUBLIC_KEY, 'hex')
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
if (!isVerified) {
|
|
308
|
+
return res.status(401).end('invalid request signature');
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
```py
|
|
313
|
+
from nacl.signing import VerifyKey
|
|
314
|
+
from nacl.exceptions import BadSignatureError
|
|
315
|
+
|
|
316
|
+
# Your public key can be found on your application in the Developer Portal
|
|
317
|
+
PUBLIC_KEY = 'APPLICATION_PUBLIC_KEY'
|
|
318
|
+
|
|
319
|
+
verify_key = VerifyKey(bytes.fromhex(PUBLIC_KEY))
|
|
320
|
+
|
|
321
|
+
signature = request.headers["X-Signature-Ed25519"]
|
|
322
|
+
timestamp = request.headers["X-Signature-Timestamp"]
|
|
323
|
+
body = request.data.decode("utf-8")
|
|
324
|
+
|
|
325
|
+
try:
|
|
326
|
+
verify_key.verify(f'{timestamp}{body}'.encode(), bytes.fromhex(signature))
|
|
327
|
+
except BadSignatureError:
|
|
328
|
+
abort(401, 'invalid request signature')
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
If you are not properly validating this signature header, we will not allow you to save your interactions URL in the Dev Portal. We will also do automated, routine security checks against your endpoint, including purposefully sending you invalid signatures. If you fail the validation, we will remove your interactions URL in the future and alert you via email and System DM.
|
|
332
|
+
|
|
333
|
+
We highly recommend checking out our [Community Resources](#DOCS_TOPICS_COMMUNITY_RESOURCES/interactions) and the libraries found there. They not only provide typing for Interactions data models, but also include decorators for API frameworks like Flask and Express to make validation easy.
|
|
334
|
+
|
|
335
|
+
### Endpoints
|
|
336
|
+
|
|
337
|
+
> info
|
|
338
|
+
> The endpoints below are not bound to the application's [Global Rate Limit](#DOCS_TOPICS_RATE_LIMITS/global-rate-limit).
|
|
339
|
+
|
|
340
|
+
## Create Interaction Response % POST /interactions/{interaction.id#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction}/{interaction.token#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object}/callback
|
|
341
|
+
|
|
342
|
+
Create a response to an Interaction from the gateway. Body is an [interaction response](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-response-object). Returns `204 No Content`.
|
|
343
|
+
|
|
344
|
+
This endpoint also supports file attachments similar to the webhook endpoints. Refer to [Uploading Files](#DOCS_REFERENCE/uploading-files) for details on uploading files and `multipart/form-data` requests.
|
|
345
|
+
|
|
346
|
+
## Get Original Interaction Response % GET /webhooks/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/{interaction.token#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object}/messages/@original
|
|
347
|
+
|
|
348
|
+
Returns the initial Interaction response. Functions the same as [Get Webhook Message](#DOCS_RESOURCES_WEBHOOK/get-webhook-message).
|
|
349
|
+
|
|
350
|
+
## Edit Original Interaction Response % PATCH /webhooks/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/{interaction.token#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object}/messages/@original
|
|
351
|
+
|
|
352
|
+
Edits the initial Interaction response. Functions the same as [Edit Webhook Message](#DOCS_RESOURCES_WEBHOOK/edit-webhook-message).
|
|
353
|
+
|
|
354
|
+
## Delete Original Interaction Response % DELETE /webhooks/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/{interaction.token#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object}/messages/@original
|
|
355
|
+
|
|
356
|
+
Deletes the initial Interaction response. Returns `204 No Content` on success. Does not support ephemeral followups.
|
|
357
|
+
|
|
358
|
+
## Create Followup Message % POST /webhooks/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/{interaction.token#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object}
|
|
359
|
+
|
|
360
|
+
Create a followup message for an Interaction. Functions the same as [Execute Webhook](#DOCS_RESOURCES_WEBHOOK/execute-webhook), but `wait` is always true, and `flags` can be set to `64` in the body to send an ephemeral message. The `thread_id`, `avatar_url`, and `username` parameters are not supported when using this endpoint for interaction followups.
|
|
361
|
+
|
|
362
|
+
## Get Followup Message % GET /webhooks/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/{interaction.token#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object}/messages/{message.id#DOCS_RESOURCES_CHANNEL/message-object}
|
|
363
|
+
|
|
364
|
+
Returns a followup message for an Interaction. Functions the same as [Get Webhook Message](#DOCS_RESOURCES_WEBHOOK/get-webhook-message). Does not support ephemeral followups.
|
|
365
|
+
|
|
366
|
+
## Edit Followup Message % PATCH /webhooks/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/{interaction.token#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object}/messages/{message.id#DOCS_RESOURCES_CHANNEL/message-object}
|
|
367
|
+
|
|
368
|
+
Edits a followup message for an Interaction. Functions the same as [Edit Webhook Message](#DOCS_RESOURCES_WEBHOOK/edit-webhook-message). Does not support ephemeral followups.
|
|
369
|
+
|
|
370
|
+
## Delete Followup Message % DELETE /webhooks/{application.id#DOCS_RESOURCES_APPLICATION/application-object}/{interaction.token#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object}/messages/{message.id#DOCS_RESOURCES_CHANNEL/message-object}
|
|
371
|
+
|
|
372
|
+
Deletes a followup message for an Interaction. Returns `204 No Content` on success. Does not support ephemeral followups.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Application Resource
|
|
2
|
+
|
|
3
|
+
### Application Object
|
|
4
|
+
|
|
5
|
+
###### Application Structure
|
|
6
|
+
|
|
7
|
+
| Field | Type | Description |
|
|
8
|
+
|------------------------|------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|
|
|
9
|
+
| id | snowflake | the id of the app |
|
|
10
|
+
| name | string | the name of the app |
|
|
11
|
+
| icon | ?string | the [icon hash](#DOCS_REFERENCE/image-formatting) of the app |
|
|
12
|
+
| description | string | the description of the app |
|
|
13
|
+
| rpc_origins? | array of strings | an array of rpc origin urls, if rpc is enabled |
|
|
14
|
+
| bot_public | boolean | when false only app owner can join the app's bot to guilds |
|
|
15
|
+
| bot_require_code_grant | boolean | when true the app's bot will only join upon completion of the full oauth2 code grant flow |
|
|
16
|
+
| terms_of_service_url? | string | the url of the app's terms of service |
|
|
17
|
+
| privacy_policy_url? | string | the url of the app's privacy policy |
|
|
18
|
+
| owner? | partial [user](#DOCS_RESOURCES_USER/user-object) object | partial user object containing info on the owner of the application |
|
|
19
|
+
| summary | string | if this application is a game sold on Discord, this field will be the summary field for the store page of its primary sku |
|
|
20
|
+
| verify_key | string | the hex encoded key for verification in interactions and the GameSDK's [GetTicket](#DOCS_GAME_SDK_APPLICATIONS/getticket) |
|
|
21
|
+
| team | ?[team](#DOCS_TOPICS_TEAMS/data-models-team-object) object | if the application belongs to a team, this will be a list of the members of that team |
|
|
22
|
+
| guild_id? | snowflake | if this application is a game sold on Discord, this field will be the guild to which it has been linked |
|
|
23
|
+
| primary_sku_id? | snowflake | if this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists |
|
|
24
|
+
| slug? | string | if this application is a game sold on Discord, this field will be the URL slug that links to the store page |
|
|
25
|
+
| cover_image? | string | the application's default rich presence invite [cover image hash](#DOCS_REFERENCE/image-formatting) |
|
|
26
|
+
| flags? | integer | the application's public [flags](#DOCS_RESOURCES_APPLICATION/application-object-application-flags) |
|
|
27
|
+
|
|
28
|
+
###### Example Application Object
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"bot_public": true,
|
|
33
|
+
"bot_require_code_grant": false,
|
|
34
|
+
"cover_image": "31deabb7e45b6c8ecfef77d2f99c81a5",
|
|
35
|
+
"description": "Test",
|
|
36
|
+
"guild_id": "290926798626357260",
|
|
37
|
+
"icon": null,
|
|
38
|
+
"id": "172150183260323840",
|
|
39
|
+
"name": "Baba O-Riley",
|
|
40
|
+
"owner": {
|
|
41
|
+
"avatar": null,
|
|
42
|
+
"discriminator": "1738",
|
|
43
|
+
"flags": 1024,
|
|
44
|
+
"id": "172150183260323840",
|
|
45
|
+
"username": "i own a bot"
|
|
46
|
+
},
|
|
47
|
+
"primary_sku_id": "172150183260323840",
|
|
48
|
+
"slug": "test",
|
|
49
|
+
"summary": "This is a game",
|
|
50
|
+
"team": {
|
|
51
|
+
"icon": "dd9b7dcfdf5351b9c3de0fe167bacbe1",
|
|
52
|
+
"id": "531992624043786253",
|
|
53
|
+
"members": [
|
|
54
|
+
{
|
|
55
|
+
"membership_state": 2,
|
|
56
|
+
"permissions": ["*"],
|
|
57
|
+
"team_id": "531992624043786253",
|
|
58
|
+
"user": {
|
|
59
|
+
"avatar": "d9e261cd35999608eb7e3de1fae3688b",
|
|
60
|
+
"discriminator": "0001",
|
|
61
|
+
"id": "511972282709709995",
|
|
62
|
+
"username": "Mr Owner"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"verify_key": "1e0a356058d627ca38a5c8c9648818061d49e49bd9da9e3ab17d98ad4d6bg2u8"
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
###### Application Flags
|
|
72
|
+
|
|
73
|
+
| Value | Name | Description |
|
|
74
|
+
|---------|----------------------------------|------------------------------|
|
|
75
|
+
| 1 << 12 | GATEWAY_PRESENCE | Intent required for bots in **100 or more servers** to receive [`presence_update` events](#DOCS_TOPICS_GATEWAY/presence-update) |
|
|
76
|
+
| 1 << 13 | GATEWAY_PRESENCE_LIMITED | Intent required for bots in under 100 servers to receive [`presence_update` events](#DOCS_TOPICS_GATEWAY/presence-update), found in Bot Settings |
|
|
77
|
+
| 1 << 14 | GATEWAY_GUILD_MEMBERS | Intent required for bots in **100 or more servers** to receive member-related events like `guild_member_add`. See list of member-related events [under `GUILD_MEMBERS`](#DOCS_TOPICS_GATEWAY/list-of-intents) |
|
|
78
|
+
| 1 << 15 | GATEWAY_GUILD_MEMBERS_LIMITED | Intent required for bots in under 100 servers to receive member-related events like `guild_member_add`, found in Bot Settings. See list of member-related events [under `GUILD_MEMBERS`](#DOCS_TOPICS_GATEWAY/list-of-intents)
|
|
79
|
+
| 1 << 16 | VERIFICATION_PENDING_GUILD_LIMIT | Indicates unusual growth of an app that prevents verification |
|
|
80
|
+
| 1 << 17 | EMBEDDED | Indicates if an app is embedded within the Discord client (currently unavailable publicly) |
|
|
81
|
+
| 1 << 18 | GATEWAY_MESSAGE_CONTENT | Intent required for bots in **100 or more servers** to receive [message content](https://support-dev.discord.com/hc/en-us/articles/4404772028055) |
|
|
82
|
+
| 1 << 19 | GATEWAY_MESSAGE_CONTENT_LIMITED | Intent required for bots in under 100 servers to receive [message content](https://support-dev.discord.com/hc/en-us/articles/4404772028055), found in Bot Settings |
|