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.
Files changed (136) hide show
  1. package/DiscordREST/types.js +6 -0
  2. package/DiscordREST/types.js.map +1 -0
  3. package/DiscordWS/index.js +2 -0
  4. package/DiscordWS/index.js.map +1 -0
  5. package/README.md +3 -0
  6. package/WS/index.js +71 -0
  7. package/WS/index.js.map +1 -0
  8. package/discord-api-docs/index.js +1 -0
  9. package/mod.js.map +1 -0
  10. package/package.json +6 -1
  11. package/types.js +1563 -0
  12. package/types.js.map +1 -0
  13. package/websocket.js +11 -0
  14. package/websocket.js.map +1 -0
  15. package/.gitmodules +0 -3
  16. package/.prettierrc.json +0 -4
  17. package/discord-api-docs/.eslintrc.json +0 -10
  18. package/discord-api-docs/.gitattributes +0 -11
  19. package/discord-api-docs/.github/ISSUE_TEMPLATE/api-bug-report.yml +0 -49
  20. package/discord-api-docs/.github/ISSUE_TEMPLATE/config.yml +0 -20
  21. package/discord-api-docs/.github/ISSUE_TEMPLATE/developer-site-bug-report.yml +0 -49
  22. package/discord-api-docs/.github/ISSUE_TEMPLATE/message-components-bug-report.yml +0 -49
  23. package/discord-api-docs/.github/ISSUE_TEMPLATE/slash-command-bug-report.yml +0 -49
  24. package/discord-api-docs/.github/workflows/test.yaml +0 -45
  25. package/discord-api-docs/.prettierignore +0 -1
  26. package/discord-api-docs/.prettierrc.json +0 -15
  27. package/discord-api-docs/CODE_OF_CONDUCT.md +0 -75
  28. package/discord-api-docs/CONTRIBUTING.md +0 -16
  29. package/discord-api-docs/README.md +0 -35
  30. package/discord-api-docs/docs/Change_Log.md +0 -474
  31. package/discord-api-docs/docs/Intro.md +0 -48
  32. package/discord-api-docs/docs/Legal.md +0 -154
  33. package/discord-api-docs/docs/Policy.md +0 -81
  34. package/discord-api-docs/docs/Reference.md +0 -476
  35. package/discord-api-docs/docs/Store_Distribution_Agreement.md +0 -179
  36. package/discord-api-docs/docs/dispatch/Branches_and_Builds.md +0 -654
  37. package/discord-api-docs/docs/dispatch/Dispatch_and_You.md +0 -17
  38. package/discord-api-docs/docs/dispatch/Error_Codes.md +0 -26
  39. package/discord-api-docs/docs/dispatch/Field_Values.md +0 -48
  40. package/discord-api-docs/docs/dispatch/List_of_Commands.md +0 -315
  41. package/discord-api-docs/docs/game_and_server_management/Alpha_and_Beta_Testing.md +0 -52
  42. package/discord-api-docs/docs/game_and_server_management/How_to_Get_Your_Game_on_Discord.md +0 -110
  43. package/discord-api-docs/docs/game_and_server_management/Special_Channels.md +0 -38
  44. package/discord-api-docs/docs/game_sdk/Achievements.md +0 -405
  45. package/discord-api-docs/docs/game_sdk/Activities.md +0 -561
  46. package/discord-api-docs/docs/game_sdk/Applications.md +0 -237
  47. package/discord-api-docs/docs/game_sdk/Discord.md +0 -443
  48. package/discord-api-docs/docs/game_sdk/Discord_Voice.md +0 -289
  49. package/discord-api-docs/docs/game_sdk/Images.md +0 -196
  50. package/discord-api-docs/docs/game_sdk/Lobbies.md +0 -1639
  51. package/discord-api-docs/docs/game_sdk/Networking.md +0 -377
  52. package/discord-api-docs/docs/game_sdk/Overlay.md +0 -195
  53. package/discord-api-docs/docs/game_sdk/Relationships.md +0 -234
  54. package/discord-api-docs/docs/game_sdk/SDK_Starter_Guide.md +0 -310
  55. package/discord-api-docs/docs/game_sdk/Storage.md +0 -312
  56. package/discord-api-docs/docs/game_sdk/Store.md +0 -555
  57. package/discord-api-docs/docs/game_sdk/Users.md +0 -178
  58. package/discord-api-docs/docs/interactions/Application_Commands.md +0 -1069
  59. package/discord-api-docs/docs/interactions/Message_Components.md +0 -454
  60. package/discord-api-docs/docs/interactions/Receiving_and_Responding.md +0 -372
  61. package/discord-api-docs/docs/interactions/Slash_Commands.md +0 -3
  62. package/discord-api-docs/docs/resources/Application.md +0 -82
  63. package/discord-api-docs/docs/resources/Audit_Log.md +0 -223
  64. package/discord-api-docs/docs/resources/Channel.md +0 -1267
  65. package/discord-api-docs/docs/resources/Emoji.md +0 -122
  66. package/discord-api-docs/docs/resources/Guild.md +0 -1157
  67. package/discord-api-docs/docs/resources/Guild_Scheduled_Event.md +0 -273
  68. package/discord-api-docs/docs/resources/Guild_Template.md +0 -148
  69. package/discord-api-docs/docs/resources/Invite.md +0 -150
  70. package/discord-api-docs/docs/resources/Stage_Instance.md +0 -106
  71. package/discord-api-docs/docs/resources/Sticker.md +0 -164
  72. package/discord-api-docs/docs/resources/User.md +0 -205
  73. package/discord-api-docs/docs/resources/Voice.md +0 -55
  74. package/discord-api-docs/docs/resources/Webhook.md +0 -281
  75. package/discord-api-docs/docs/rich_presence/Best_Practices.md +0 -88
  76. package/discord-api-docs/docs/rich_presence/FAQ.md +0 -45
  77. package/discord-api-docs/docs/rich_presence/How_To.md +0 -302
  78. package/discord-api-docs/docs/rich_presence/Launch_Checklist.md +0 -46
  79. package/discord-api-docs/docs/topics/Certified_Devices.md +0 -200
  80. package/discord-api-docs/docs/topics/Community_Resources.md +0 -98
  81. package/discord-api-docs/docs/topics/Gateway.md +0 -1600
  82. package/discord-api-docs/docs/topics/OAuth2.md +0 -427
  83. package/discord-api-docs/docs/topics/Opcodes_and_Status_Codes.md +0 -306
  84. package/discord-api-docs/docs/topics/Permissions.md +0 -229
  85. package/discord-api-docs/docs/topics/RPC.md +0 -1597
  86. package/discord-api-docs/docs/topics/Rate_Limits.md +0 -126
  87. package/discord-api-docs/docs/topics/Teams.md +0 -80
  88. package/discord-api-docs/docs/topics/Threads.md +0 -163
  89. package/discord-api-docs/docs/topics/Voice_Connections.md +0 -282
  90. package/discord-api-docs/images/API_center.gif +0 -0
  91. package/discord-api-docs/images/ask-to-join.gif +0 -0
  92. package/discord-api-docs/images/available-published.png +0 -0
  93. package/discord-api-docs/images/button-styles.png +0 -0
  94. package/discord-api-docs/images/certified-device.png +0 -0
  95. package/discord-api-docs/images/command-with-groups-subcommands-parameters.png +0 -0
  96. package/discord-api-docs/images/command-with-groups-subcommands.png +0 -0
  97. package/discord-api-docs/images/command.png +0 -0
  98. package/discord-api-docs/images/cpp-files-sdk.png +0 -0
  99. package/discord-api-docs/images/create-store-channel.png +0 -0
  100. package/discord-api-docs/images/deferred-example.png +0 -0
  101. package/discord-api-docs/images/desktop-select.png +0 -0
  102. package/discord-api-docs/images/game-overlay-sdk-invite.gif +0 -0
  103. package/discord-api-docs/images/game-overlay-sdk-voice-settings.png +0 -0
  104. package/discord-api-docs/images/game-overlay-sdk-voice-widget.png +0 -0
  105. package/discord-api-docs/images/gift-code-creation.png +0 -0
  106. package/discord-api-docs/images/lib-linked-sdk.png +0 -0
  107. package/discord-api-docs/images/message-command.png +0 -0
  108. package/discord-api-docs/images/mobile-select.png +0 -0
  109. package/discord-api-docs/images/previous-new-server-background.png +0 -0
  110. package/discord-api-docs/images/rp-actionable.png +0 -0
  111. package/discord-api-docs/images/rp-all-fields.png +0 -0
  112. package/discord-api-docs/images/rp-bad-art.png +0 -0
  113. package/discord-api-docs/images/rp-good-art.png +0 -0
  114. package/discord-api-docs/images/rp-legend.png +0 -0
  115. package/discord-api-docs/images/rp-long-strings.png +0 -0
  116. package/discord-api-docs/images/rp-non-actionable.png +0 -0
  117. package/discord-api-docs/images/rp-not-all-fields.png +0 -0
  118. package/discord-api-docs/images/rp-profile-example-1.png +0 -0
  119. package/discord-api-docs/images/rp-profile-example-2.png +0 -0
  120. package/discord-api-docs/images/rp-short-strings.png +0 -0
  121. package/discord-api-docs/images/server-banner-example.png +0 -0
  122. package/discord-api-docs/images/server-banner-margin-top.png +0 -0
  123. package/discord-api-docs/images/sku-management.png +0 -0
  124. package/discord-api-docs/images/snowflake.png +0 -0
  125. package/discord-api-docs/images/snowflake_original_size.png +0 -0
  126. package/discord-api-docs/images/spectate.gif +0 -0
  127. package/discord-api-docs/images/team-2fa.png +0 -0
  128. package/discord-api-docs/images/team-make-app.png +0 -0
  129. package/discord-api-docs/images/team-page.png +0 -0
  130. package/discord-api-docs/images/transfer-app-to-team.png +0 -0
  131. package/discord-api-docs/images/user-command.png +0 -0
  132. package/discord-api-docs/package-lock.json +0 -3186
  133. package/discord-api-docs/package.json +0 -38
  134. package/discord-api-docs/tsconfig.eslint.json +0 -4
  135. package/discord-api-docs/tsconfig.json +0 -19
  136. package/tsconfig.json +0 -24
@@ -1,1600 +0,0 @@
1
- # Gateways
2
-
3
- Gateways are Discord's form of real-time communication over secure WebSockets. Clients will receive events and data over the gateway they are connected to and send data over the REST API. The API for interacting with Gateways is complex and fairly unforgiving, therefore it's highly recommended you read _all_ of the following documentation before writing a custom implementation.
4
-
5
- The Discord Gateway has a versioning system separate from the HTTP APIs. The documentation herein is only for the latest version in the following table, unless otherwise specified.
6
-
7
- Important note: Not all event fields are documented, in particular, fields prefixed with an underscore are considered _internal fields_ and should not be relied on. We may change the format at any time.
8
-
9
- ###### Gateway Versions
10
-
11
- | Version | Status |
12
- |---------|----------------------------------|
13
- | 9 | Available |
14
- | 8 | Available |
15
- | 7 | Doesn't look like anything to me |
16
- | 6 | Deprecated |
17
- | 5 | Discontinued |
18
- | 4 | Discontinued |
19
-
20
- ## Payloads
21
-
22
- ###### Gateway Payload Structure
23
-
24
- | Field | Type | Description |
25
- |-------|-------------------------|-----------------------------------------------------------------------------------------|
26
- | op | integer | [opcode](#DOCS_TOPICS_OPCODES_AND_STATUS_CODES/gateway-gateway-opcodes) for the payload |
27
- | d | ?mixed (any JSON value) | event data |
28
- | s | ?integer \* | sequence number, used for resuming sessions and heartbeats |
29
- | t | ?string \* | the event name for this payload |
30
-
31
- \* `s` and `t` are `null` when `op` is not `0` (Gateway Dispatch Opcode).
32
-
33
- ### Sending Payloads
34
-
35
- Packets sent from the client to the Gateway API are encapsulated within a [gateway payload object](#DOCS_TOPICS_GATEWAY/sending-payloads-example-gateway-dispatch) and must have the proper opcode and data object set. The payload object can then be serialized in the format of choice (see [ETF/JSON](#DOCS_TOPICS_GATEWAY/etfjson)), and sent over the websocket. Payloads to the gateway are limited to a maximum of 4096 bytes sent, going over this will cause a connection termination with error code 4002.
36
-
37
- ###### Example Gateway Dispatch
38
-
39
- ```json
40
- {
41
- "op": 0,
42
- "d": {},
43
- "s": 42,
44
- "t": "GATEWAY_EVENT_NAME"
45
- }
46
- ```
47
-
48
- ### Receiving Payloads
49
-
50
- Receiving payloads with the Gateway API is slightly more complex than sending. When using the JSON encoding with [Payload Compression](#DOCS_TOPICS_GATEWAY/payload-compression) enabled, the Gateway has the option of sending payloads as compressed JSON binaries using zlib, meaning your library _must_ detect (see [RFC1950 2.2](https://tools.ietf.org/html/rfc1950#section-2.2)) and decompress these payloads before attempting to parse them. Otherwise the gateway does implement a shared compression context between messages sent, see [Transport Compression](#DOCS_TOPICS_GATEWAY/transport-compression).
51
-
52
- ## Encoding and Compression
53
-
54
- #### ETF/JSON
55
-
56
- When initially creating and handshaking connections to the Gateway, a user can choose whether they wish to communicate over plain-text JSON or binary [ETF](https://erlang.org/doc/apps/erts/erl_ext_dist.html).
57
-
58
- ##### Using ETF
59
-
60
- While using ETF there are some additional constraints to note:
61
-
62
- - Snowflake IDs are transmitted as 64-bit integers or strings over ETF.
63
- - The client must not send compressed messages to the server.
64
- - Payloads must use string keys, atom keys will lead to a 4002 decode error.
65
-
66
- See [erlpack](https://github.com/discord/erlpack) for an ETF implementation example.
67
-
68
- #### Payload Compression
69
-
70
- When using JSON encoding with payload compression enabled (`compress: true` in identify), the Gateway may optionally send zlib-compressed payloads (see [RFC1950 2.2](https://tools.ietf.org/html/rfc1950#section-2.2)). Your library _must_ detect and decompress these payloads to plain-text JSON before attempting to parse them. If you are using payload compression, the gateway does not implement a shared compression context between messages sent. Payload compression will be disabled if you use transport compression (see below).
71
-
72
- #### Transport Compression
73
-
74
- Currently the only available transport compression option is `zlib-stream`. You will need to run all received packets through a shared zlib context, as seen in the example below. Every connection to the gateway should use its own unique zlib context.
75
-
76
- ###### Transport Compression Example
77
-
78
- ```python
79
- # Z_SYNC_FLUSH suffix
80
- ZLIB_SUFFIX = b'\x00\x00\xff\xff'
81
- # initialize a buffer to store chunks
82
- buffer = bytearray()
83
- # create a zlib inflation context to run chunks through
84
- inflator = zlib.decompressobj()
85
-
86
- # ...
87
- def on_websocket_message(msg):
88
- # always push the message data to your cache
89
- buffer.extend(msg)
90
-
91
- # check if the last four bytes are equal to ZLIB_SUFFIX
92
- if len(msg) < 4 or msg[-4:] != ZLIB_SUFFIX:
93
- return
94
-
95
- # if the message *does* end with ZLIB_SUFFIX,
96
- # get the full message by decompressing the buffers
97
- # NOTE: the message is utf-8 encoded.
98
- msg = inflator.decompress(buffer)
99
- buffer = bytearray()
100
-
101
- # here you can treat `msg` as either JSON or ETF encoded,
102
- # depending on your `encoding` param
103
- ```
104
-
105
- ## Connecting to the Gateway
106
-
107
- ### Connecting
108
-
109
- ###### Gateway URL Query String Params
110
-
111
- | Field | Type | Description | Accepted Values |
112
- |-----------|---------|-----------------------------------------------|----------------------------------------------------------------------------|
113
- | v | integer | Gateway Version to use | see [Gateway versions](#DOCS_TOPICS_GATEWAY/gateways-gateway-versions) |
114
- | encoding | string | The encoding of received gateway packets | 'json' or 'etf' |
115
- | compress? | string | The (optional) compression of gateway packets | 'zlib-stream' |
116
-
117
- The first step in establishing connectivity to the gateway is requesting a valid websocket endpoint from the API. This can be done through either the [Get Gateway](#DOCS_TOPICS_GATEWAY/get-gateway) or the [Get Gateway Bot](#DOCS_TOPICS_GATEWAY/get-gateway-bot) endpoint.
118
-
119
- With the resulting payload, you can now open a websocket connection to the "url" (or endpoint) specified. Generally, it is a good idea to explicitly pass the gateway version and encoding. For example, we may connect to `wss://gateway.discord.gg/?v=9&encoding=json`.
120
-
121
- Once connected, the client should immediately receive an [Opcode 10 Hello](#DOCS_TOPICS_GATEWAY/hello) payload, with information on the connection's heartbeat interval:
122
-
123
- ###### Example Gateway Hello
124
-
125
- ```json
126
- {
127
- "op": 10,
128
- "d": {
129
- "heartbeat_interval": 45000
130
- }
131
- }
132
- ```
133
-
134
- ### Heartbeating
135
-
136
- After receiving [Opcode 10 Hello](#DOCS_TOPICS_GATEWAY/hello), the client may begin sending [Opcode 1 Heartbeat](#DOCS_TOPICS_GATEWAY/heartbeat) payloads after `heartbeat_interval * jitter` milliseconds (where jitter is a random value between 0 and 1), and every `heartbeat_interval` milliseconds thereafter. You may send heartbeats before this interval elapses, but you should avoid doing so unless necessary. There is already tolerance in the `heartbeat_interval` that will cover network latency, so you do not need to account for it in your own implementation - waiting the precise interval will suffice.
137
-
138
- The gateway may request a heartbeat from the client in some situations by sending an [Opcode 1 Heartbeat](#DOCS_TOPICS_GATEWAY/heartbeat). When this occurs, the client should immediately send an [Opcode 1 Heartbeat](#DOCS_TOPICS_GATEWAY/heartbeat) without waiting the remainder of the current interval.
139
-
140
- Any time the client sends a heartbeat, the gateway will respond with [Opcode 11 Heartbeat ACK](#DOCS_TOPICS_GATEWAY/heartbeating-example-gateway-heartbeat-ack), a successful *acknowledgement* of their last heartbeat:
141
-
142
- ###### Example Gateway Heartbeat ACK
143
-
144
- ```json
145
- {
146
- "op": 11
147
- }
148
- ```
149
-
150
- If a client does not receive a heartbeat ack between its attempts at sending heartbeats, this may be due to a failed or "zombied" connection. The client should then immediately terminate the connection with a non-1000 close code, reconnect, and attempt to [Resume](#DOCS_TOPICS_GATEWAY/resuming).
151
-
152
- > info
153
- > In the event of a service outage where you stay connected to the gateway, you should continue to heartbeat and receive ACKs. The gateway will eventually respond and issue a session once it's able to.
154
-
155
- ### Identifying
156
-
157
- Next, the client is expected to send an [Opcode 2 Identify](#DOCS_TOPICS_GATEWAY/identify):
158
-
159
- ###### Example Gateway Identify
160
-
161
- This is a minimal `IDENTIFY` payload. `IDENTIFY` supports additional optional fields for other session properties, such as payload compression, or an initial presence state. See the [Identify Structure](#DOCS_TOPICS_GATEWAY/identify) for a more complete example of all options you can pass in.
162
-
163
- ```json
164
- {
165
- "op": 2,
166
- "d": {
167
- "token": "my_token",
168
- "intents": 513,
169
- "properties": {
170
- "$os": "linux",
171
- "$browser": "my_library",
172
- "$device": "my_library"
173
- }
174
- }
175
- }
176
- ```
177
-
178
- If the payload is valid, the gateway will respond with a [Ready](#DOCS_TOPICS_GATEWAY/ready) event. Your client is now considered in a "connected" state. Clients are limited by [maximum concurrency](#DOCS_TOPICS_GATEWAY/session-start-limit-object) when [Identifying](#DOCS_TOPICS_GATEWAY/identify); if they exceed this limit, the gateway will respond with an [Opcode 9 Invalid Session](#DOCS_TOPICS_GATEWAY/invalid-session). It is important to note that although the ready event contains a large portion of the required initial state, some information (such as guilds and their members) is sent asynchronously (see [Guild Create](#DOCS_TOPICS_GATEWAY/guild-create) event).
179
-
180
- > warn
181
- > Clients are limited to 1000 `IDENTIFY` calls to the websocket in a 24-hour period. This limit is global and across all shards, but does not include `RESUME` calls. Upon hitting this limit, all active sessions for the bot will be terminated, the bot's token will be reset, and the owner will receive an email notification. It's up to the owner to update their application with the new token.
182
-
183
- ## Resuming
184
-
185
- The Internet is a scary place. Disconnections happen, especially with persistent connections. Due to Discord's architecture, this is a semi-regular event and should be expected and handled. Discord has a process for "resuming" (or reconnecting) a connection that allows the client to replay any lost events from the last sequence number they received in the exact same way they would receive them normally.
186
-
187
- Your client should store the `session_id` from the [Ready](#DOCS_TOPICS_GATEWAY/ready), and the sequence number of the last event it received. When your client detects that it has been disconnected, it should completely close the connection and open a new one (following the same strategy as [Connecting](#DOCS_TOPICS_GATEWAY/connecting)). Once the new connection has been opened, the client should send a [Gateway Resume](#DOCS_TOPICS_GATEWAY/resume):
188
-
189
- ###### Example Gateway Resume
190
-
191
- ```json
192
- {
193
- "op": 6,
194
- "d": {
195
- "token": "my_token",
196
- "session_id": "session_id_i_stored",
197
- "seq": 1337
198
- }
199
- }
200
- ```
201
-
202
- If successful, the gateway will respond by replaying all missed events in order, finishing with a [Resumed](#DOCS_TOPICS_GATEWAY/resumed) event to signal replay has finished, and all subsequent events are new. It's also possible that your client cannot reconnect in time to resume, in which case the client will receive a [Opcode 9 Invalid Session](#DOCS_TOPICS_GATEWAY/invalid-session) and is expected to wait a random amount of time—between 1 and 5 seconds—then send a fresh [Opcode 2 Identify](#DOCS_TOPICS_GATEWAY/identify).
203
-
204
- ### Disconnections
205
-
206
- If the gateway ever issues a disconnect to your client, it will provide a close event code that you can use to properly handle the disconnection. A full list of these close codes can be found in the [Response Codes](#DOCS_TOPICS_OPCODES_AND_STATUS_CODES/gateway-gateway-close-event-codes) documentation.
207
-
208
- When you close the connection to the gateway with the close code 1000 or 1001, your session will be invalidated and your bot will appear offline. If you simply close the TCP connection, or use a different close code, the bot session will remain active and timeout after a few minutes. This can be useful for a reconnect, which will resume the previous session.
209
-
210
- ## Gateway Intents
211
-
212
- > info
213
- > Intents are optionally supported on the v6 gateway but required as of v8
214
-
215
- Maintaining a stateful application can be difficult when it comes to the amount of data you're expected to process, especially at scale. Gateway Intents are a system to help you lower that computational burden.
216
-
217
- When [identifying](#DOCS_TOPICS_GATEWAY/identifying) to the gateway, you can specify an `intents` parameter which allows you to conditionally subscribe to pre-defined "intents", groups of events defined by Discord. If you do not specify a certain intent, you will not receive any of the gateway events that are batched into that group. The valid intents are:
218
-
219
- ### List of Intents
220
-
221
- ```
222
- GUILDS (1 << 0)
223
- - GUILD_CREATE
224
- - GUILD_UPDATE
225
- - GUILD_DELETE
226
- - GUILD_ROLE_CREATE
227
- - GUILD_ROLE_UPDATE
228
- - GUILD_ROLE_DELETE
229
- - CHANNEL_CREATE
230
- - CHANNEL_UPDATE
231
- - CHANNEL_DELETE
232
- - CHANNEL_PINS_UPDATE
233
- - THREAD_CREATE
234
- - THREAD_UPDATE
235
- - THREAD_DELETE
236
- - THREAD_LIST_SYNC
237
- - THREAD_MEMBER_UPDATE
238
- - THREAD_MEMBERS_UPDATE *
239
- - STAGE_INSTANCE_CREATE
240
- - STAGE_INSTANCE_UPDATE
241
- - STAGE_INSTANCE_DELETE
242
-
243
- GUILD_MEMBERS (1 << 1)
244
- - GUILD_MEMBER_ADD
245
- - GUILD_MEMBER_UPDATE
246
- - GUILD_MEMBER_REMOVE
247
- - THREAD_MEMBERS_UPDATE *
248
-
249
- GUILD_BANS (1 << 2)
250
- - GUILD_BAN_ADD
251
- - GUILD_BAN_REMOVE
252
-
253
- GUILD_EMOJIS_AND_STICKERS (1 << 3)
254
- - GUILD_EMOJIS_UPDATE
255
- - GUILD_STICKERS_UPDATE
256
-
257
- GUILD_INTEGRATIONS (1 << 4)
258
- - GUILD_INTEGRATIONS_UPDATE
259
- - INTEGRATION_CREATE
260
- - INTEGRATION_UPDATE
261
- - INTEGRATION_DELETE
262
-
263
- GUILD_WEBHOOKS (1 << 5)
264
- - WEBHOOKS_UPDATE
265
-
266
- GUILD_INVITES (1 << 6)
267
- - INVITE_CREATE
268
- - INVITE_DELETE
269
-
270
- GUILD_VOICE_STATES (1 << 7)
271
- - VOICE_STATE_UPDATE
272
-
273
- GUILD_PRESENCES (1 << 8)
274
- - PRESENCE_UPDATE
275
-
276
- GUILD_MESSAGES (1 << 9)
277
- - MESSAGE_CREATE
278
- - MESSAGE_UPDATE
279
- - MESSAGE_DELETE
280
- - MESSAGE_DELETE_BULK
281
-
282
- GUILD_MESSAGE_REACTIONS (1 << 10)
283
- - MESSAGE_REACTION_ADD
284
- - MESSAGE_REACTION_REMOVE
285
- - MESSAGE_REACTION_REMOVE_ALL
286
- - MESSAGE_REACTION_REMOVE_EMOJI
287
-
288
- GUILD_MESSAGE_TYPING (1 << 11)
289
- - TYPING_START
290
-
291
- DIRECT_MESSAGES (1 << 12)
292
- - MESSAGE_CREATE
293
- - MESSAGE_UPDATE
294
- - MESSAGE_DELETE
295
- - CHANNEL_PINS_UPDATE
296
-
297
- DIRECT_MESSAGE_REACTIONS (1 << 13)
298
- - MESSAGE_REACTION_ADD
299
- - MESSAGE_REACTION_REMOVE
300
- - MESSAGE_REACTION_REMOVE_ALL
301
- - MESSAGE_REACTION_REMOVE_EMOJI
302
-
303
- DIRECT_MESSAGE_TYPING (1 << 14)
304
- - TYPING_START
305
-
306
- GUILD_SCHEDULED_EVENTS (1 << 16)
307
- - GUILD_SCHEDULED_EVENT_CREATE
308
- - GUILD_SCHEDULED_EVENT_UPDATE
309
- - GUILD_SCHEDULED_EVENT_DELETE
310
- - GUILD_SCHEDULED_EVENT_USER_ADD
311
- - GUILD_SCHEDULED_EVENT_USER_REMOVE
312
- ```
313
-
314
- \* [Thread Members Update](#DOCS_TOPICS_GATEWAY/thread-members-update) contains different data depending on which intents are used.
315
-
316
- ### Caveats
317
-
318
- Any [events not defined in an intent](#DOCS_TOPICS_GATEWAY/commands-and-events-gateway-events) are considered "passthrough" and will always be sent to you.
319
-
320
- [Guild Member Update](#DOCS_TOPICS_GATEWAY/guild-member-update) is sent for current-user updates regardless of whether the `GUILD_MEMBERS` intent is set.
321
-
322
- [Guild Create](#DOCS_TOPICS_GATEWAY/guild-create) and [Request Guild Members](#DOCS_TOPICS_GATEWAY/request-guild-members) are uniquely affected by intents. See these sections for more information.
323
-
324
- [Thread Members Update](#DOCS_TOPICS_GATEWAY/thread-members-update) by default only includes if the current user was added to or removed from a thread. To receive these updates for other users, request the `GUILD_MEMBERS` [Gateway Intent](#DOCS_TOPICS_GATEWAY/gateway-intents).
325
-
326
- If you specify an `intents` value in your `IDENTIFY` payload that is *invalid*, the socket will close with a [`4013` close code](#DOCS_TOPICS_OPCODES_AND_STATUS_CODES/gateway-gateway-close-event-codes). An invalid intent is one that is not meaningful and not documented above.
327
-
328
- If you specify an `intents` value in your `IDENTIFY` payload that is *disallowed*, the socket will close with a [`4014` close code](#DOCS_TOPICS_OPCODES_AND_STATUS_CODES/gateway-gateway-close-event-codes). A disallowed intent is a privileged intent that has not been approved for your bot.
329
-
330
- Bots in under 100 guilds can enable these intents in the bot tab of the developer dashboard. Verified bots can get access to privileged intents when getting verified, or by writing into support after getting verified.
331
-
332
- ### Privileged Intents
333
-
334
- > warn
335
- > Message content will become a privileged intent in 2022. [Learn more here](https://support-dev.discord.com/hc/en-us/articles/4404772028055).
336
-
337
- Some intents are defined as "Privileged" due to the sensitive nature of the data. Those intents are:
338
-
339
- - `GUILD_PRESENCES`
340
- - `GUILD_MEMBERS`
341
-
342
- To specify these intents in your `IDENTIFY` payload, you must visit your application page in the Developer Portal and enable the toggle for each Privileged Intent that you wish to use. If your bot qualifies for [verification](https://dis.gd/bot-verification), you must first [verify your bot](https://support.discord.com/hc/en-us/articles/360040720412-Bot-Verification-and-Data-Whitelisting) and request access to these intents during the verification process. If your bot is already verified and you need to request additional privileged intents, [contact support](https://dis.gd/support).
343
-
344
- Events under the `GUILD_PRESENCES` and `GUILD_MEMBERS` intents are turned **off by default on all gateway versions**. If you are using **Gateway v6**, you will receive those events if you are authorized to receive them and have enabled the intents in the Developer Portal. You do not need to use Intents on Gateway v6 to receive these events; you just need to enable the flags.
345
-
346
- If you are using **Gateway v8** or above, Intents are mandatory and must be specified when identifying.
347
-
348
- In addition to the gateway restrictions described here, Discord's REST API is also affected by Privileged Intents. Specifically, to use the [List Guild Members](#DOCS_RESOURCES_GUILD/list-guild-members) endpoint, you must have the `GUILD_MEMBERS` intent enabled for your application. This behavior is independent of whether the intent is set during `IDENTIFY`.
349
-
350
- ## Rate Limiting
351
-
352
- > info
353
- > This section is about Gateway rate limits, not [HTTP API rate limits](#DOCS_TOPICS_RATE_LIMITS/)
354
-
355
- Clients are allowed to send 120 [gateway commands](#DOCS_TOPICS_GATEWAY/commands-and-events) every 60 seconds, meaning you can send an average of 2 commands per second. Clients who surpass this limit are immediately disconnected from the Gateway, and similarly to the HTTP API, repeat offenders will have their API access revoked. Clients also have a limit of [concurrent](#DOCS_TOPICS_GATEWAY/session-start-limit-object) [Identify](#DOCS_TOPICS_GATEWAY/identify) requests allowed per 5 seconds. If you hit this limit, the Gateway will respond with an [Opcode 9 Invalid Session](#DOCS_TOPICS_GATEWAY/invalid-session).
356
-
357
- ## Tracking State
358
-
359
- Most of a client's state is provided during the initial [Ready](#DOCS_TOPICS_GATEWAY/ready) event and the [Guild Create](#DOCS_TOPICS_GATEWAY/guild-create) events that immediately follow. As objects are further created/updated/deleted, other events are sent to notify the client of these changes and to provide the new or updated data. To avoid excessive API calls, Discord expects clients to locally cache as many _relevant_ object states as possible, and to update them as gateway events are received.
360
-
361
- An example of state tracking can be found with member status caching. When initially connecting to the gateway, the client receives information regarding the online status of guild members (online, idle, dnd, offline). To keep this state updated, a client must track and parse [Presence Update](#DOCS_TOPICS_GATEWAY/presence-update) events as they are received, and apply the provided data to the cached member objects.
362
-
363
- For larger bots, client state can grow to be quite large. We recommend only storing objects in memory that are needed for a bot's operation. Many bots, for example, just respond to user input through chat commands. These bots may only need to keep guild information (like guild/channel roles and permissions) in memory, since [MESSAGE_CREATE](#DOCS_TOPICS_GATEWAY/message-create) and [MESSAGE_UPDATE](#DOCS_TOPICS_GATEWAY/message-update) events have the full member object available.
364
-
365
- ## Guild Availability
366
-
367
- When connecting to the gateway as a bot user, guilds that the bot is a part of will start out as unavailable. Don't fret! The gateway will automatically attempt to reconnect on your behalf. As guilds become available to you, you will receive [Guild Create](#DOCS_TOPICS_GATEWAY/guild-create) events.
368
-
369
- ## Sharding
370
-
371
- As bots grow and are added to an increasing number of guilds, some developers may find it necessary to break or split portions of their bots operations into separate logical processes. As such, Discord gateways implement a method of user-controlled guild sharding which allows for splitting events across a number of gateway connections. Guild sharding is entirely user controlled, and requires no state-sharing between separate connections to operate.
372
-
373
- To enable sharding on a connection, the user should send the `shard` array in the [Identify](#DOCS_TOPICS_GATEWAY/identify) payload. The first item in this array should be the zero-based integer value of the current shard, while the second represents the total number of shards. DMs will only be sent to shard 0. To calculate what events will be sent to what shard, the following formula can be used:
374
-
375
- ###### Sharding Formula
376
-
377
- ```python
378
- shard_id = (guild_id >> 22) % num_shards
379
- ```
380
-
381
- As an example, if you wanted to split the connection between three shards, you'd use the following values for `shard` for each connection: `[0, 3]`, `[1, 3]`, and `[2, 3]`. Note that only the first shard (`[0, 3]`) would receive DMs.
382
-
383
- Note that `num_shards` does not relate to, or limit, the total number of potential sessions—it is only used for *routing* traffic. As such, sessions do not have to be identified in an evenly distributed manner when sharding. You can establish multiple sessions with the same `[shard_id, num_shards]`, or sessions with different `num_shards` values. This allows you to create sessions that will handle more or less traffic than others for more fine-tuned load balancing, or orchestrate "zero-downtime" scaling/updating by handing off traffic to a new deployment of sessions with a higher or lower `num_shards` count that are prepared in parallel.
384
-
385
- ###### Max Concurrency
386
-
387
- If you have multiple shards, you may start them concurrently based on the [`max_concurrency`](#DOCS_TOPICS_GATEWAY/session-start-limit-object) value returned to you on session start. Which shards you can start concurrently are assigned based on a key for each shard. The rate limit key for a given shard can be computed with
388
-
389
- ```
390
- rate_limit_key = shard_id % max_concurrency
391
- ```
392
-
393
- This puts your shards into "buckets" of `max_concurrency` size. When you start your bot, you may start up to `max_concurrency` shards at a time, and you must start them by "bucket" **in order**. To explain another way, let's say you have 16 shards, and your `max_concurrency` is 16:
394
-
395
- ```
396
- shard_id: 0, rate limit key (0 % 16): 0
397
- shard_id: 1, rate limit key (1 % 16): 1
398
- shard_id: 2, rate limit key (2 % 16): 2
399
- shard_id: 3, rate limit key (3 % 16): 3
400
- shard_id: 4, rate limit key (4 % 16): 4
401
- shard_id: 5, rate limit key (5 % 16): 5
402
- shard_id: 6, rate limit key (6 % 16): 6
403
- shard_id: 7, rate limit key (7 % 16): 7
404
- shard_id: 8, rate limit key (8 % 16): 8
405
- shard_id: 9, rate limit key (9 % 16): 9
406
- shard_id: 10, rate limit key (10 % 16): 10
407
- shard_id: 11, rate limit key (11 % 16): 11
408
- shard_id: 12, rate limit key (12 % 16): 12
409
- shard_id: 13, rate limit key (13 % 16): 13
410
- shard_id: 14, rate limit key (14 % 16): 14
411
- shard_id: 15, rate limit key (15 % 16): 15
412
- ```
413
-
414
- You may start all 16 of your shards at once, because each has a `rate_limit_key` which fills the bucket of 16 shards. However, let's say you had 32 shards:
415
-
416
- ```
417
- shard_id: 0, rate limit key (0 % 16): 0
418
- shard_id: 1, rate limit key (1 % 16): 1
419
- shard_id: 2, rate limit key (2 % 16): 2
420
- shard_id: 3, rate limit key (3 % 16): 3
421
- shard_id: 4, rate limit key (4 % 16): 4
422
- shard_id: 5, rate limit key (5 % 16): 5
423
- shard_id: 6, rate limit key (6 % 16): 6
424
- shard_id: 7, rate limit key (7 % 16): 7
425
- shard_id: 8, rate limit key (8 % 16): 8
426
- shard_id: 9, rate limit key (9 % 16): 9
427
- shard_id: 10, rate limit key (10 % 16): 10
428
- shard_id: 11, rate limit key (11 % 16): 11
429
- shard_id: 12, rate limit key (12 % 16): 12
430
- shard_id: 13, rate limit key (13 % 16): 13
431
- shard_id: 14, rate limit key (14 % 16): 14
432
- shard_id: 15, rate limit key (15 % 16): 15
433
- shard_id: 16, rate limit key (16 % 16): 0
434
- shard_id: 17, rate limit key (17 % 16): 1
435
- shard_id: 18, rate limit key (18 % 16): 2
436
- shard_id: 19, rate limit key (19 % 16): 3
437
- shard_id: 20, rate limit key (20 % 16): 4
438
- shard_id: 21, rate limit key (21 % 16): 5
439
- shard_id: 22, rate limit key (22 % 16): 6
440
- shard_id: 23, rate limit key (23 % 16): 7
441
- shard_id: 24, rate limit key (24 % 16): 8
442
- shard_id: 25, rate limit key (25 % 16): 9
443
- shard_id: 26, rate limit key (26 % 16): 10
444
- shard_id: 27, rate limit key (27 % 16): 11
445
- shard_id: 28, rate limit key (28 % 16): 12
446
- shard_id: 29, rate limit key (29 % 16): 13
447
- shard_id: 30, rate limit key (30 % 16): 14
448
- shard_id: 31, rate limit key (31 % 16): 15
449
- ```
450
-
451
- In this case, you must start the shard buckets **in "order"**. That means that you can start shard 0 -> shard 15 concurrently, and then you can start shard 16 -> shard 31.
452
-
453
- ## Sharding for Very Large Bots
454
-
455
- If you own a bot that is near or in over 150,000 guilds, there are some additional considerations you must take around sharding. Please file a support-ticket to get moved to the sharding for big bots, when you reach near this amount of servers. You can contact the discord support using [https://dis.gd/contact](https://dis.gd/contact).
456
-
457
- The number of shards you run must be a multiple of a fixed number we will determine when reaching out to you. If you attempt to start your bot with an invalid number of shards, your websocket connection will close with a 4010 Invalid Shard opcode. The gateway bot bootstrap endpoint will return the correct amount of shards, so if you're already using this endpoint to determine your number of shards, you shouldn't require any further changes.
458
-
459
- The session start limit for these bots will also be increased from 1000 to `max(2000, (guild_count / 1000) * 3)` per day. You also receive an increased `max_concurrency`, the number of [shards you can concurrently start](#DOCS_TOPICS_GATEWAY/session-start-limit-object).
460
-
461
- Finally, the [Get Current User Guilds](#DOCS_RESOURCES_USER/get-current-user-guilds) endpoint will no longer return results for your bot. We will be creating a new endpoint that is more shard-aware to iterate through your bot's guilds if needed.
462
-
463
- ## Commands and Events
464
-
465
- Commands are requests made to the gateway socket by a client.
466
-
467
- ###### Gateway Commands
468
-
469
- | name | description |
470
- |---------------------------------------------------------------------|--------------------------------------------------------------|
471
- | [Identify](#DOCS_TOPICS_GATEWAY/identify) | triggers the initial handshake with the gateway |
472
- | [Resume](#DOCS_TOPICS_GATEWAY/resume) | resumes a dropped gateway connection |
473
- | [Heartbeat](#DOCS_TOPICS_GATEWAY/heartbeat) | maintains an active gateway connection |
474
- | [Request Guild Members](#DOCS_TOPICS_GATEWAY/request-guild-members) | requests members for a guild |
475
- | [Update Voice State](#DOCS_TOPICS_GATEWAY/update-voice-state) | joins, moves, or disconnects the client from a voice channel |
476
- | [Update Presence](#DOCS_TOPICS_GATEWAY/update-presence) | updates a client's presence |
477
-
478
- Events are payloads sent over the socket to a client that correspond to events in Discord.
479
-
480
- ###### Gateway Events
481
-
482
- | name | description |
483
- |-------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
484
- | [Hello](#DOCS_TOPICS_GATEWAY/hello) | defines the heartbeat interval |
485
- | [Ready](#DOCS_TOPICS_GATEWAY/ready) | contains the initial state information |
486
- | [Resumed](#DOCS_TOPICS_GATEWAY/resumed) | response to [Resume](#DOCS_TOPICS_GATEWAY/resume) |
487
- | [Reconnect](#DOCS_TOPICS_GATEWAY/reconnect) | server is going away, client should reconnect to gateway and resume |
488
- | [Invalid Session](#DOCS_TOPICS_GATEWAY/invalid-session) | failure response to [Identify](#DOCS_TOPICS_GATEWAY/identify) or [Resume](#DOCS_TOPICS_GATEWAY/resume) or invalid active session |
489
- | [Channel Create](#DOCS_TOPICS_GATEWAY/channel-create) | new guild channel created |
490
- | [Channel Update](#DOCS_TOPICS_GATEWAY/channel-update) | channel was updated |
491
- | [Channel Delete](#DOCS_TOPICS_GATEWAY/channel-delete) | channel was deleted |
492
- | [Channel Pins Update](#DOCS_TOPICS_GATEWAY/channel-pins-update) | message was pinned or unpinned |
493
- | [Thread Create](#DOCS_TOPICS_GATEWAY/thread-create) | thread created, also sent when being added to a private thread |
494
- | [Thread Update](#DOCS_TOPICS_GATEWAY/thread-update) | thread was updated |
495
- | [Thread Delete](#DOCS_TOPICS_GATEWAY/thread-delete) | thread was deleted |
496
- | [Thread List Sync](#DOCS_TOPICS_GATEWAY/thread-list-sync) | sent when gaining access to a channel, contains all active threads in that channel |
497
- | [Thread Member Update](#DOCS_TOPICS_GATEWAY/thread-member-update) | [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) for the current user was updated |
498
- | [Thread Members Update](#DOCS_TOPICS_GATEWAY/thread-members-update) | some user(s) were added to or removed from a thread |
499
- | [Guild Create](#DOCS_TOPICS_GATEWAY/guild-create) | lazy-load for unavailable guild, guild became available, or user joined a new guild |
500
- | [Guild Update](#DOCS_TOPICS_GATEWAY/guild-update) | guild was updated |
501
- | [Guild Delete](#DOCS_TOPICS_GATEWAY/guild-delete) | guild became unavailable, or user left/was removed from a guild |
502
- | [Guild Ban Add](#DOCS_TOPICS_GATEWAY/guild-ban-add) | user was banned from a guild |
503
- | [Guild Ban Remove](#DOCS_TOPICS_GATEWAY/guild-ban-remove) | user was unbanned from a guild |
504
- | [Guild Emojis Update](#DOCS_TOPICS_GATEWAY/guild-emojis-update) | guild emojis were updated |
505
- | [Guild Stickers Update](#DOCS_TOPICS_GATEWAY/guild-stickers-update) | guild stickers were updated |
506
- | [Guild Integrations Update](#DOCS_TOPICS_GATEWAY/guild-integrations-update) | guild integration was updated |
507
- | [Guild Member Add](#DOCS_TOPICS_GATEWAY/guild-member-add) | new user joined a guild |
508
- | [Guild Member Remove](#DOCS_TOPICS_GATEWAY/guild-member-remove) | user was removed from a guild |
509
- | [Guild Member Update](#DOCS_TOPICS_GATEWAY/guild-member-update) | guild member was updated |
510
- | [Guild Members Chunk](#DOCS_TOPICS_GATEWAY/guild-members-chunk) | response to [Request Guild Members](#DOCS_TOPICS_GATEWAY/request-guild-members) |
511
- | [Guild Role Create](#DOCS_TOPICS_GATEWAY/guild-role-create) | guild role was created |
512
- | [Guild Role Update](#DOCS_TOPICS_GATEWAY/guild-role-update) | guild role was updated |
513
- | [Guild Role Delete](#DOCS_TOPICS_GATEWAY/guild-role-delete) | guild role was deleted |
514
- | [Guild Scheduled Event Create](#DOCS_TOPICS_GATEWAY/guild-scheduled-event-create) | guild scheduled event was created |
515
- | [Guild Scheduled Event Update](#DOCS_TOPICS_GATEWAY/guild-scheduled-event-update) | guild scheduled event was updated |
516
- | [Guild Scheduled Event Delete](#DOCS_TOPICS_GATEWAY/guild-scheduled-event-delete) | guild scheduled event was deleted |
517
- | [Guild Scheduled Event User Add](#DOCS_TOPICS_GATEWAY/guild-scheduled-event-user-add) | user subscribed to a guild scheduled event |
518
- | [Guild Scheduled Event User Remove](#DOCS_TOPICS_GATEWAY/guild-scheduled-event-user-remove) | user unsubscribed from a guild scheduled event |
519
- | [Integration Create](#DOCS_TOPICS_GATEWAY/integration-create) | guild integration was created |
520
- | [Integration Update](#DOCS_TOPICS_GATEWAY/integration-update) | guild integration was updated |
521
- | [Integration Delete](#DOCS_TOPICS_GATEWAY/integration-delete) | guild integration was deleted |
522
- | [Interaction Create](#DOCS_TOPICS_GATEWAY/interaction-create) | user used an interaction, such as an [Application Command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/) |
523
- | [Invite Create](#DOCS_TOPICS_GATEWAY/invite-create) | invite to a channel was created |
524
- | [Invite Delete](#DOCS_TOPICS_GATEWAY/invite-delete) | invite to a channel was deleted |
525
- | [Message Create](#DOCS_TOPICS_GATEWAY/message-create) | message was created |
526
- | [Message Update](#DOCS_TOPICS_GATEWAY/message-update) | message was edited |
527
- | [Message Delete](#DOCS_TOPICS_GATEWAY/message-delete) | message was deleted |
528
- | [Message Delete Bulk](#DOCS_TOPICS_GATEWAY/message-delete-bulk) | multiple messages were deleted at once |
529
- | [Message Reaction Add](#DOCS_TOPICS_GATEWAY/message-reaction-add) | user reacted to a message |
530
- | [Message Reaction Remove](#DOCS_TOPICS_GATEWAY/message-reaction-remove) | user removed a reaction from a message |
531
- | [Message Reaction Remove All](#DOCS_TOPICS_GATEWAY/message-reaction-remove-all) | all reactions were explicitly removed from a message |
532
- | [Message Reaction Remove Emoji](#DOCS_TOPICS_GATEWAY/message-reaction-remove-emoji) | all reactions for a given emoji were explicitly removed from a message |
533
- | [Presence Update](#DOCS_TOPICS_GATEWAY/presence-update) | user was updated |
534
- | [Stage Instance Create](#DOCS_TOPICS_GATEWAY/stage-instance-create) | stage instance was created |
535
- | [Stage Instance Delete](#DOCS_TOPICS_GATEWAY/stage-instance-delete) | stage instance was deleted or closed |
536
- | [Stage Instance Update](#DOCS_TOPICS_GATEWAY/stage-instance-update) | stage instance was updated |
537
- | [Typing Start](#DOCS_TOPICS_GATEWAY/typing-start) | user started typing in a channel |
538
- | [User Update](#DOCS_TOPICS_GATEWAY/user-update) | properties about the user changed |
539
- | [Voice State Update](#DOCS_TOPICS_GATEWAY/voice-state-update) | someone joined, left, or moved a voice channel |
540
- | [Voice Server Update](#DOCS_TOPICS_GATEWAY/voice-server-update) | guild's voice server was updated |
541
- | [Webhooks Update](#DOCS_TOPICS_GATEWAY/webhooks-update) | guild channel webhook was created, update, or deleted |
542
-
543
- ### Event Names
544
-
545
- Event names are in standard constant form, fully upper-cased and replacing all spaces with underscores. For instance, [Channel Create](#DOCS_TOPICS_GATEWAY/channel-create) would be `CHANNEL_CREATE` and [Voice State Update](#DOCS_TOPICS_GATEWAY/voice-state-update) would be `VOICE_STATE_UPDATE`. Within the following documentation, they have been left in standard English form to aid in readability.
546
-
547
- #### Identify
548
-
549
- Used to trigger the initial handshake with the gateway.
550
-
551
- ###### Identify Structure
552
-
553
- | Field | Type | Description | Default |
554
- |----------------------|------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|---------|
555
- | token | string | authentication token | - |
556
- | properties | object | [connection properties](#DOCS_TOPICS_GATEWAY/identify-identify-connection-properties) | - |
557
- | compress? | boolean | whether this connection supports compression of packets | false |
558
- | large_threshold? | integer | value between 50 and 250, total number of members where the gateway will stop sending offline members in the guild member list | 50 |
559
- | shard? | array of two integers (shard_id, num_shards) | used for [Guild Sharding](#DOCS_TOPICS_GATEWAY/sharding) | - |
560
- | presence? | [update presence](#DOCS_TOPICS_GATEWAY/update-presence) object | presence structure for initial presence information | - |
561
- | intents | integer | the [Gateway Intents](#DOCS_TOPICS_GATEWAY/gateway-intents) you wish to receive | - |
562
-
563
- ###### Identify Connection Properties
564
-
565
- | Field | Type | Description |
566
- |-----------|--------|-----------------------|
567
- | \$os | string | your operating system |
568
- | \$browser | string | your library name |
569
- | \$device | string | your library name |
570
-
571
- ###### Example Identify
572
-
573
- ```json
574
- {
575
- "op": 2,
576
- "d": {
577
- "token": "my_token",
578
- "properties": {
579
- "$os": "linux",
580
- "$browser": "disco",
581
- "$device": "disco"
582
- },
583
- "compress": true,
584
- "large_threshold": 250,
585
- "shard": [0, 1],
586
- "presence": {
587
- "activities": [{
588
- "name": "Cards Against Humanity",
589
- "type": 0
590
- }],
591
- "status": "dnd",
592
- "since": 91879201,
593
- "afk": false
594
- },
595
- // This intent represents 1 << 0 for GUILDS, 1 << 1 for GUILD_MEMBERS, and 1 << 2 for GUILD_BANS
596
- // This connection will only receive the events defined in those three intents
597
- "intents": 7
598
- }
599
- }
600
- ```
601
-
602
- #### Resume
603
-
604
- Used to replay missed events when a disconnected client resumes.
605
-
606
- ###### Resume Structure
607
-
608
- | Field | Type | Description |
609
- |------------|---------|-------------------------------|
610
- | token | string | session token |
611
- | session_id | string | session id |
612
- | seq | integer | last sequence number received |
613
-
614
- ###### Example Resume
615
-
616
- ```json
617
- {
618
- "op": 6,
619
- "d": {
620
- "token": "randomstring",
621
- "session_id": "evenmorerandomstring",
622
- "seq": 1337
623
- }
624
- }
625
- ```
626
-
627
- #### Heartbeat
628
-
629
- Used to maintain an active gateway connection. Must be sent every `heartbeat_interval` milliseconds after the [Opcode 10 Hello](#DOCS_TOPICS_GATEWAY/hello) payload is received. The inner `d` key is the last sequence number—`s`—received by the client. If you have not yet received one, send `null`.
630
-
631
- ###### Example Heartbeat
632
-
633
- ```
634
- {
635
- "op": 1,
636
- "d": 251
637
- }
638
- ```
639
-
640
- #### Request Guild Members
641
-
642
- Used to request all members for a guild or a list of guilds. When initially connecting, if you don't have the `GUILD_PRESENCES` [Gateway Intent](#DOCS_TOPICS_GATEWAY/gateway-intents), or if the guild is over 75k members, it will only send members who are in voice, plus the member for you (the connecting user). Otherwise, if a guild has over `large_threshold` members (value in the [Gateway Identify](#DOCS_TOPICS_GATEWAY/identify)), it will only send members who are online, have a role, have a nickname, or are in a voice channel, and if it has under `large_threshold` members, it will send all members. If a client wishes to receive additional members, they need to explicitly request them via this operation. The server will send [Guild Members Chunk](#DOCS_TOPICS_GATEWAY/guild-members-chunk) events in response with up to 1000 members per chunk until all members that match the request have been sent.
643
-
644
- Due to our privacy and infrastructural concerns with this feature, there are some limitations that apply:
645
-
646
- - `GUILD_PRESENCES` intent is required to set `presences = true`. Otherwise, it will always be false
647
- - `GUILD_MEMBERS` intent is required to request the entire member list—`(query=‘’, limit=0<=n)`
648
- - You will be limited to requesting 1 `guild_id` per request
649
- - Requesting a prefix (`query` parameter) will return a maximum of 100 members
650
- - Requesting `user_ids` will continue to be limited to returning 100 members
651
-
652
- ###### Guild Request Members Structure
653
-
654
- | Field | Type | Description | Required |
655
- |------------|----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
656
- | guild_id | snowflake | id of the guild to get members for | true |
657
- | query? | string | string that username starts with, or an empty string to return all members | one of query or user_ids |
658
- | limit | integer | maximum number of members to send matching the `query`; a limit of `0` can be used with an empty string `query` to return all members | true when specifying query |
659
- | presences? | boolean | used to specify if we want the presences of the matched members | false |
660
- | user_ids? | snowflake or array of snowflakes | used to specify which users you wish to fetch | one of query or user_ids |
661
- | nonce? | string | nonce to identify the [Guild Members Chunk](#DOCS_TOPICS_GATEWAY/guild-members-chunk) response | false |
662
-
663
- > info
664
- > Nonce can only be up to 32 bytes. If you send an invalid nonce it will be ignored and the reply member_chunk(s) will not have a nonce set.
665
-
666
- ###### Guild Request Members
667
-
668
- ```json
669
- {
670
- "op": 8,
671
- "d": {
672
- "guild_id": "41771983444115456",
673
- "query": "",
674
- "limit": 0
675
- }
676
- }
677
- ```
678
-
679
- #### Update Voice State
680
-
681
- Sent when a client wants to join, move, or disconnect from a voice channel.
682
-
683
- ###### Gateway Voice State Update Structure
684
-
685
- | Field | Type | Description |
686
- |------------|------------|----------------------------------------------------------------------|
687
- | guild_id | snowflake | id of the guild |
688
- | channel_id | ?snowflake | id of the voice channel client wants to join (null if disconnecting) |
689
- | self_mute | boolean | is the client muted |
690
- | self_deaf | boolean | is the client deafened |
691
-
692
- ###### Example Gateway Voice State Update
693
-
694
- ```json
695
- {
696
- "op": 4,
697
- "d": {
698
- "guild_id": "41771983423143937",
699
- "channel_id": "127121515262115840",
700
- "self_mute": false,
701
- "self_deaf": false
702
- }
703
- }
704
- ```
705
-
706
- #### Update Presence
707
-
708
- Sent by the client to indicate a presence or status update.
709
-
710
- ###### Gateway Presence Update Structure
711
-
712
- | Field | Type | Description |
713
- |------------|-------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
714
- | since | ?integer | unix time (in milliseconds) of when the client went idle, or null if the client is not idle |
715
- | activities | array of [activity](#DOCS_TOPICS_GATEWAY/activity-object) objects | the user's activities |
716
- | status | string | the user's new [status](#DOCS_TOPICS_GATEWAY/update-presence-status-types) |
717
- | afk | boolean | whether or not the client is afk |
718
-
719
- ###### Status Types
720
-
721
- | Status | Description |
722
- |-----------|--------------------------------|
723
- | online | Online |
724
- | dnd | Do Not Disturb |
725
- | idle | AFK |
726
- | invisible | Invisible and shown as offline |
727
- | offline | Offline |
728
-
729
- ###### Example Gateway Presence Update
730
-
731
- ```json
732
- {
733
- "op": 3,
734
- "d": {
735
- "since": 91879201,
736
- "activities": [{
737
- "name": "Save the Oxford Comma",
738
- "type": 0
739
- }],
740
- "status": "online",
741
- "afk": false
742
- }
743
- }
744
- ```
745
-
746
- ### Connecting and Resuming
747
-
748
- #### Hello
749
-
750
- Sent on connection to the websocket. Defines the heartbeat interval that the client should heartbeat to.
751
-
752
- ###### Hello Structure
753
-
754
- | Field | Type | Description |
755
- |--------------------|---------|-----------------------------------------------------------------|
756
- | heartbeat_interval | integer | the interval (in milliseconds) the client should heartbeat with |
757
-
758
- ###### Example Hello
759
-
760
- ```json
761
- {
762
- "op": 10,
763
- "d": {
764
- "heartbeat_interval": 45000
765
- }
766
- }
767
- ```
768
-
769
- #### Ready
770
-
771
- The ready event is dispatched when a client has completed the initial handshake with the gateway (for new sessions). The ready event can be the largest and most complex event the gateway will send, as it contains all the state required for a client to begin interacting with the rest of the platform.
772
-
773
- `guilds` are the guilds of which your bot is a member. They start out as unavailable when you connect to the gateway. As they become available, your bot will be notified via [Guild Create](#DOCS_TOPICS_GATEWAY/guild-create) events.
774
-
775
- ###### Ready Event Fields
776
-
777
- | Field | Type | Description |
778
- |------------------|--------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------|
779
- | v | integer | [gateway version](#DOCS_TOPICS_GATEWAY/gateways-gateway-versions) |
780
- | user | [user](#DOCS_RESOURCES_USER/user-object) object | information about the user including email |
781
- | guilds | array of [Unavailable Guild](#DOCS_RESOURCES_GUILD/unavailable-guild-object) objects | the guilds the user is in |
782
- | session_id | string | used for resuming connections |
783
- | shard? | array of two integers (shard_id, num_shards) | the [shard information](#DOCS_TOPICS_GATEWAY/sharding) associated with this session, if sent when identifying |
784
- | application | partial [application object](#DOCS_RESOURCES_APPLICATION/application-object) | contains `id` and `flags` |
785
-
786
- #### Resumed
787
-
788
- The resumed event is dispatched when a client has sent a [resume payload](#DOCS_TOPICS_GATEWAY/resume) to the gateway (for resuming existing sessions).
789
-
790
- #### Reconnect
791
-
792
- The reconnect event is dispatched when a client should reconnect to the gateway (and resume their existing session, if they have one). This event usually occurs during deploys to migrate sessions gracefully off old hosts.
793
-
794
- ###### Example Gateway Reconnect
795
-
796
- ```json
797
- {
798
- "op": 7,
799
- "d": null
800
- }
801
- ```
802
-
803
- #### Invalid Session
804
-
805
- Sent to indicate one of at least three different situations:
806
-
807
- - the gateway could not initialize a session after receiving an [Opcode 2 Identify](#DOCS_TOPICS_GATEWAY/identify)
808
- - the gateway could not resume a previous session after receiving an [Opcode 6 Resume](#DOCS_TOPICS_GATEWAY/resume)
809
- - the gateway has invalidated an active session and is requesting client action
810
-
811
- The inner `d` key is a boolean that indicates whether the session may be resumable. See [Connecting](#DOCS_TOPICS_GATEWAY/connecting) and [Resuming](#DOCS_TOPICS_GATEWAY/resuming) for more information.
812
-
813
- ###### Example Gateway Invalid Session
814
-
815
- ```json
816
- {
817
- "op": 9,
818
- "d": false
819
- }
820
- ```
821
-
822
- ### Channels
823
-
824
- #### Channel Create
825
-
826
- Sent when a new guild channel is created, relevant to the current user. The inner payload is a [channel](#DOCS_RESOURCES_CHANNEL/channel-object) object.
827
-
828
- #### Channel Update
829
-
830
- Sent when a channel is updated. The inner payload is a [channel](#DOCS_RESOURCES_CHANNEL/channel-object) object. This is not sent when the field `last_message_id` is altered. To keep track of the last_message_id changes, you must listen for [Message Create](#DOCS_TOPICS_GATEWAY/message-create) events.
831
-
832
- #### Channel Delete
833
-
834
- Sent when a channel relevant to the current user is deleted. The inner payload is a [channel](#DOCS_RESOURCES_CHANNEL/channel-object) object.
835
-
836
- #### Thread Create
837
-
838
- Sent when a thread is created, relevant to the current user, or when the current user is added to a thread. The inner payload is a [channel](#DOCS_RESOURCES_CHANNEL/channel-object) object.
839
- - When a thread is created, includes an additional `newly_created` boolean field.
840
- - When being added to an existing private thread, includes a [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) object.
841
-
842
- #### Thread Update
843
-
844
- Sent when a thread is updated. The inner payload is a [channel](#DOCS_RESOURCES_CHANNEL/channel-object) object. This is not sent when the field `last_message_id` is altered. To keep track of the last_message_id changes, you must listen for [Message Create](#DOCS_TOPICS_GATEWAY/message-create) events.
845
-
846
- #### Thread Delete
847
-
848
- Sent when a thread relevant to the current user is deleted. The inner payload is a subset of the [channel](#DOCS_RESOURCES_CHANNEL/channel-object) object, containing just the `id`, `guild_id`, `parent_id`, and `type` fields.
849
-
850
- #### Thread List Sync
851
-
852
- Sent when the current user _gains_ access to a channel.
853
-
854
- ###### Thread List Sync Event Fields
855
-
856
- | Field | Type | Description |
857
- |--------------|--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
858
- | guild_id | snowflake | the id of the guild |
859
- | channel_ids? | array of snowflakes | the parent channel ids whose threads are being synced. If omitted, then threads were synced for the entire guild. This array may contain channel_ids that have no active threads as well, so you know to clear that data. |
860
- | threads | array of [channel](#DOCS_RESOURCES_CHANNEL/channel-object) objects | all active threads in the given channels that the current user can access |
861
- | members | array of [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) objects | all thread member objects from the synced threads for the current user, indicating which threads the current user has been added to |
862
-
863
- #### Thread Member Update
864
-
865
- Sent when the [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) object for the current user is updated. The inner payload is a [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) object with an extra `guild_id` field. This event is documented for completeness, but unlikely to be used by most bots. For bots, this event largely is just a signal that you are a member of the thread. See the [threads docs](#DOCS_TOPICS_THREADS) for more details.
866
-
867
- ###### Thread Member Update Event Extra Fields
868
-
869
- | Field | Type | Description |
870
- |-----------|--------------|--------------------------|
871
- | guild_id | snowflake | the id of the guild |
872
-
873
-
874
- #### Thread Members Update
875
-
876
- Sent when anyone is added to or removed from a thread. If the current user does not have the `GUILD_MEMBERS` [Gateway Intent](#DOCS_TOPICS_GATEWAY/gateway-intents), then this event will only be sent if the current user was added to or removed from the thread.
877
-
878
- ###### Thread Members Update Event Fields
879
-
880
- | Field | Type | Description |
881
- |----------------------|--------------------------------------------------------------------------------|-----------------------------------------------------------------|
882
- | id | snowflake | the id of the thread |
883
- | guild_id | snowflake | the id of the guild |
884
- | member_count | integer | the approximate number of members in the thread, capped at 50 |
885
- | added_members?\* | array of [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) objects | the users who were added to the thread |
886
- | removed_member_ids? | array of snowflakes | the id of the users who were removed from the thread |
887
-
888
- \* In this gateway event, the thread member objects will also include the [guild member](#DOCS_RESOURCES_GUILD/guild-member-object) and nullable [presence](#DOCS_TOPICS_GATEWAY/presence) objects for each added thread member.
889
-
890
- #### Channel Pins Update
891
-
892
- Sent when a message is pinned or unpinned in a text channel. This is not sent when a pinned message is deleted.
893
-
894
- ###### Channel Pins Update Event Fields
895
-
896
- | Field | Type | Description |
897
- |---------------------|--------------------|--------------------------------------------------------------|
898
- | guild_id? | snowflake | the id of the guild |
899
- | channel_id | snowflake | the id of the channel |
900
- | last_pin_timestamp? | ?ISO8601 timestamp | the time at which the most recent pinned message was pinned |
901
-
902
- ### Guilds
903
-
904
- #### Guild Create
905
-
906
- This event can be sent in three different scenarios:
907
-
908
- 1. When a user is initially connecting, to lazily load and backfill information for all unavailable guilds sent in the [Ready](#DOCS_TOPICS_GATEWAY/ready) event. Guilds that are unavailable due to an outage will send a [Guild Delete](#DOCS_TOPICS_GATEWAY/guild-delete) event.
909
- 2. When a Guild becomes available again to the client.
910
- 3. When the current user joins a new Guild.
911
-
912
- The inner payload is a [guild](#DOCS_RESOURCES_GUILD/guild-object) object, with all the extra fields specified.
913
-
914
- > warn
915
- > If your bot does not have the `GUILD_PRESENCES` [Gateway Intent](#DOCS_TOPICS_GATEWAY/gateway-intents), or if the guild has over 75k members, members and presences returned in this event will only contain your bot and users in voice channels.
916
-
917
- #### Guild Update
918
-
919
- Sent when a guild is updated. The inner payload is a [guild](#DOCS_RESOURCES_GUILD/guild-object) object.
920
-
921
- #### Guild Delete
922
-
923
- Sent when a guild becomes or was already unavailable due to an outage, or when the user leaves or is removed from a guild. The inner payload is an [unavailable guild](#DOCS_RESOURCES_GUILD/unavailable-guild-object) object. If the `unavailable` field is not set, the user was removed from the guild.
924
-
925
- #### Guild Ban Add
926
-
927
- Sent when a user is banned from a guild.
928
-
929
- ###### Guild Ban Add Event Fields
930
-
931
- | Field | Type | Description |
932
- |----------|---------------------------------------------------|-----------------|
933
- | guild_id | snowflake | id of the guild |
934
- | user | a [user](#DOCS_RESOURCES_USER/user-object) object | the banned user |
935
-
936
- #### Guild Ban Remove
937
-
938
- Sent when a user is unbanned from a guild.
939
-
940
- ###### Guild Ban Remove Event Fields
941
-
942
- | Field | Type | Description |
943
- |----------|---------------------------------------------------|-------------------|
944
- | guild_id | snowflake | id of the guild |
945
- | user | a [user](#DOCS_RESOURCES_USER/user-object) object | the unbanned user |
946
-
947
- #### Guild Emojis Update
948
-
949
- Sent when a guild's emojis have been updated.
950
-
951
- ###### Guild Emojis Update Event Fields
952
-
953
- | Field | Type | Description |
954
- |----------|-----------|-------------------------------------------------------|
955
- | guild_id | snowflake | id of the guild |
956
- | emojis | array | array of [emojis](#DOCS_RESOURCES_EMOJI/emoji-object) |
957
-
958
- #### Guild Stickers Update
959
-
960
- Sent when a guild's stickers have been updated.
961
-
962
- ###### Guild Stickers Update Event Fields
963
-
964
- | Field | Type | Description |
965
- |----------|-----------|-------------------------------------------------------------|
966
- | guild_id | snowflake | id of the guild |
967
- | stickers | array | array of [stickers](#DOCS_RESOURCES_STICKER/sticker-object) |
968
-
969
- #### Guild Integrations Update
970
-
971
- Sent when a guild integration is updated.
972
-
973
- ###### Guild Integrations Update Event Fields
974
-
975
- | Field | Type | Description |
976
- |----------|-----------|-------------------------------------------------|
977
- | guild_id | snowflake | id of the guild whose integrations were updated |
978
-
979
- #### Guild Member Add
980
-
981
- > warn
982
- > If using [Gateway Intents](#DOCS_TOPICS_GATEWAY/gateway-intents), the `GUILD_MEMBERS` intent will be required to receive this event.
983
-
984
- Sent when a new user joins a guild. The inner payload is a [guild member](#DOCS_RESOURCES_GUILD/guild-member-object) object with an extra `guild_id` key:
985
-
986
- ###### Guild Member Add Extra Fields
987
-
988
- | Field | Type | Description |
989
- |----------|-----------|-----------------|
990
- | guild_id | snowflake | id of the guild |
991
-
992
- #### Guild Member Remove
993
-
994
- > warn
995
- > If using [Gateway Intents](#DOCS_TOPICS_GATEWAY/gateway-intents), the `GUILD_MEMBERS` intent will be required to receive this event.
996
-
997
- Sent when a user is removed from a guild (leave/kick/ban).
998
-
999
- ###### Guild Member Remove Event Fields
1000
-
1001
- | Field | Type | Description |
1002
- |----------|---------------------------------------------------|--------------------------|
1003
- | guild_id | snowflake | the id of the guild |
1004
- | user | a [user](#DOCS_RESOURCES_USER/user-object) object | the user who was removed |
1005
-
1006
- #### Guild Member Update
1007
-
1008
- > warn
1009
- > If using [Gateway Intents](#DOCS_TOPICS_GATEWAY/gateway-intents), the `GUILD_MEMBERS` intent will be required to receive this event.
1010
-
1011
- Sent when a guild member is updated. This will also fire when the user object of a guild member changes.
1012
-
1013
- ###### Guild Member Update Event Fields
1014
-
1015
- | Field | Type | Description |
1016
- | ----------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1017
- | guild_id | snowflake | the id of the guild |
1018
- | roles | array of snowflakes | user role ids |
1019
- | user | a [user](#DOCS_RESOURCES_USER/user-object) object | the user |
1020
- | nick? | ?string | nickname of the user in the guild |
1021
- | avatar | ?string | the member's [guild avatar hash](#DOCS_REFERENCE/image-formatting) |
1022
- | joined_at | ?ISO8601 timestamp | when the user joined the guild |
1023
- | premium_since? | ?ISO8601 timestamp | when the user starting [boosting](https://support.discord.com/hc/en-us/articles/360028038352-Server-Boosting-) the guild |
1024
- | deaf? | boolean | whether the user is deafened in voice channels |
1025
- | mute? | boolean | whether the user is muted in voice channels |
1026
- | pending? | boolean | whether the user has not yet passed the guild's [Membership Screening](#DOCS_RESOURCES_GUILD/membership-screening-object) requirements |
1027
- | communication_disabled_until? | ?ISO8601 timestamp | when the user's [timeout](https://support.discord.com/hc/en-us/articles/4413305239191-Time-Out-FAQ) will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out |
1028
-
1029
- #### Guild Members Chunk
1030
-
1031
- Sent in response to [Guild Request Members](#DOCS_TOPICS_GATEWAY/request-guild-members).
1032
- You can use the `chunk_index` and `chunk_count` to calculate how many chunks are left for your request.
1033
-
1034
- ###### Guild Members Chunk Event Fields
1035
-
1036
- | Field | Type | Description |
1037
- |-------------|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
1038
- | guild_id | snowflake | the id of the guild |
1039
- | members | array of [guild member](#DOCS_RESOURCES_GUILD/guild-member-object) objects | set of guild members |
1040
- | chunk_index | integer | the chunk index in the expected chunks for this response (0 <= chunk\_index < chunk\_count) |
1041
- | chunk_count | integer | the total number of expected chunks for this response |
1042
- | not_found? | array | if passing an invalid id to `REQUEST_GUILD_MEMBERS`, it will be returned here |
1043
- | presences? | array of [presence](#DOCS_TOPICS_GATEWAY/presence) objects | if passing true to `REQUEST_GUILD_MEMBERS`, presences of the returned members will be here |
1044
- | nonce? | string | the nonce used in the [Guild Members Request](#DOCS_TOPICS_GATEWAY/request-guild-members) |
1045
-
1046
- #### Guild Role Create
1047
-
1048
- Sent when a guild role is created.
1049
-
1050
- ###### Guild Role Create Event Fields
1051
-
1052
- | Field | Type | Description |
1053
- |----------|-------------------------------------------------------|---------------------|
1054
- | guild_id | snowflake | the id of the guild |
1055
- | role | a [role](#DOCS_TOPICS_PERMISSIONS/role-object) object | the role created |
1056
-
1057
- #### Guild Role Update
1058
-
1059
- Sent when a guild role is updated.
1060
-
1061
- ###### Guild Role Update Event Fields
1062
-
1063
- | Field | Type | Description |
1064
- |----------|-------------------------------------------------------|---------------------|
1065
- | guild_id | snowflake | the id of the guild |
1066
- | role | a [role](#DOCS_TOPICS_PERMISSIONS/role-object) object | the role updated |
1067
-
1068
- #### Guild Role Delete
1069
-
1070
- Sent when a guild role is deleted.
1071
-
1072
- ###### Guild Role Delete Event Fields
1073
-
1074
- | Field | Type | Description |
1075
- |----------|-----------|-----------------|
1076
- | guild_id | snowflake | id of the guild |
1077
- | role_id | snowflake | id of the role |
1078
-
1079
- ### Guild Scheduled Event Create
1080
-
1081
- Sent when a guild scheduled event is created. The inner payload is a [guild scheduled event](#DOCS_RESOURCES_GUILD_SCHEDULED_EVENT/guild-scheduled-event-object) object.
1082
-
1083
- ### Guild Scheduled Event Update
1084
-
1085
- Sent when a guild scheduled event is updated. The inner payload is a [guild scheduled event](#DOCS_RESOURCES_GUILD_SCHEDULED_EVENT/guild-scheduled-event-object) object.
1086
-
1087
- ### Guild Scheduled Event Delete
1088
-
1089
- Sent when a guild scheduled event is deleted. The inner payload is a [guild scheduled event](#DOCS_RESOURCES_GUILD_SCHEDULED_EVENT/guild-scheduled-event-object) object.
1090
-
1091
- ### Guild Scheduled Event User Add
1092
-
1093
- Sent when a user has subscribed to a guild scheduled event.
1094
-
1095
- ###### Guild Scheduled Event User Add Event Fields
1096
-
1097
- | Field | Type | Description |
1098
- | ------------------------ | --------- | ------------------------------- |
1099
- | guild_scheduled_event_id | snowflake | id of the guild scheduled event |
1100
- | user_id | snowflake | id of the user |
1101
- | guild_id | snowflake | id of the guild |
1102
-
1103
- ### Guild Scheduled Event User Remove
1104
-
1105
- Sent when a user has unsubscribed from a guild scheduled event.
1106
-
1107
- ###### Guild Scheduled Event User Remove Event Fields
1108
-
1109
- | Field | Type | Description |
1110
- | ------------------------ | --------- | ------------------------------- |
1111
- | guild_scheduled_event_id | snowflake | id of the guild scheduled event |
1112
- | user_id | snowflake | id of the user |
1113
- | guild_id | snowflake | id of the guild |
1114
-
1115
- ### Integrations
1116
-
1117
- #### Integration Create
1118
-
1119
- Sent when an integration is created. The inner payload is a [integration](#DOCS_RESOURCES_GUILD/integration-object) object with an additional `guild_id` key:
1120
-
1121
- ###### Integration Create Event Additional Fields
1122
-
1123
- | Field | Type | Description |
1124
- |----------|-----------|-----------------|
1125
- | guild_id | snowflake | id of the guild |
1126
-
1127
- #### Integration Update
1128
-
1129
- Sent when an integration is updated. The inner payload is a [integration](#DOCS_RESOURCES_GUILD/integration-object) object with an additional `guild_id` key:
1130
-
1131
- ###### Integration Update Event Additional Fields
1132
-
1133
- | Field | Type | Description |
1134
- |----------|-----------|-----------------|
1135
- | guild_id | snowflake | id of the guild |
1136
-
1137
- #### Integration Delete
1138
-
1139
- Sent when an integration is deleted.
1140
-
1141
- ###### Integration Delete Event Fields
1142
-
1143
- | Field | Type | Description |
1144
- |-----------------|-----------|---------------------------------------------------------------|
1145
- | id | snowflake | integration id |
1146
- | guild_id | snowflake | id of the guild |
1147
- | application_id? | snowflake | id of the bot/OAuth2 application for this discord integration |
1148
-
1149
- ### Invites
1150
-
1151
- #### Invite Create
1152
-
1153
- Sent when a new invite to a channel is created.
1154
-
1155
- ###### Invite Create Event Fields
1156
-
1157
- | Field | Type | Description |
1158
- |---------------------|------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
1159
- | channel_id | snowflake | the channel the invite is for |
1160
- | code | string | the unique invite [code](#DOCS_RESOURCES_INVITE/invite-object) |
1161
- | created_at | ISO8601 timestamp | the time at which the invite was created |
1162
- | guild_id? | snowflake | the guild of the invite |
1163
- | inviter? | [user](#DOCS_RESOURCES_USER/user-object) object | the user that created the invite |
1164
- | max_age | integer | how long the invite is valid for (in seconds) |
1165
- | max_uses | integer | the maximum number of times the invite can be used |
1166
- | target_type? | integer | the [type of target](#DOCS_RESOURCES_INVITE/invite-object-invite-target-types) for this voice channel invite |
1167
- | target_user? | [user](#DOCS_RESOURCES_USER/user-object) object | the user whose stream to display for this voice channel stream invite |
1168
- | target_application? | partial [application](#DOCS_RESOURCES_APPLICATION/application-object) object | the embedded application to open for this voice channel embedded application invite |
1169
- | temporary | boolean | whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role) |
1170
- | uses | integer | how many times the invite has been used (always will be 0) |
1171
-
1172
- #### Invite Delete
1173
-
1174
- Sent when an invite is deleted.
1175
-
1176
- ###### Invite Delete Event Fields
1177
-
1178
- | Field | Type | Description |
1179
- |------------|-----------|----------------------------------------------------------------|
1180
- | channel_id | snowflake | the channel of the invite |
1181
- | guild_id? | snowflake | the guild of the invite |
1182
- | code | string | the unique invite [code](#DOCS_RESOURCES_INVITE/invite-object) |
1183
-
1184
- ### Messages
1185
-
1186
- #### Message Create
1187
-
1188
- Sent when a message is created. The inner payload is a [message](#DOCS_RESOURCES_CHANNEL/message-object) object.
1189
-
1190
- #### Message Update
1191
-
1192
- Sent when a message is updated. The inner payload is a [message](#DOCS_RESOURCES_CHANNEL/message-object) object.
1193
-
1194
- > warn
1195
- > Unlike creates, message updates may contain only a subset of the full message object payload (but will always contain an id and channel_id).
1196
-
1197
- #### Message Delete
1198
-
1199
- Sent when a message is deleted.
1200
-
1201
- ###### Message Delete Event Fields
1202
-
1203
- | Field | Type | Description |
1204
- |------------|-----------|-----------------------|
1205
- | id | snowflake | the id of the message |
1206
- | channel_id | snowflake | the id of the channel |
1207
- | guild_id? | snowflake | the id of the guild |
1208
-
1209
- #### Message Delete Bulk
1210
-
1211
- Sent when multiple messages are deleted at once.
1212
-
1213
- ###### Message Delete Bulk Event Fields
1214
-
1215
- | Field | Type | Description |
1216
- |------------|---------------------|-------------------------|
1217
- | ids | array of snowflakes | the ids of the messages |
1218
- | channel_id | snowflake | the id of the channel |
1219
- | guild_id? | snowflake | the id of the guild |
1220
-
1221
- #### Message Reaction Add
1222
-
1223
- Sent when a user adds a reaction to a message.
1224
-
1225
- ###### Message Reaction Add Event Fields
1226
-
1227
- | Field | Type | Description |
1228
- |------------|--------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
1229
- | user_id | snowflake | the id of the user |
1230
- | channel_id | snowflake | the id of the channel |
1231
- | message_id | snowflake | the id of the message |
1232
- | guild_id? | snowflake | the id of the guild |
1233
- | member? | [member](#DOCS_RESOURCES_GUILD/guild-member-object) object | the member who reacted if this happened in a guild |
1234
- | emoji | a partial [emoji](#DOCS_RESOURCES_EMOJI/emoji-object) object | the emoji used to react - [example](#DOCS_RESOURCES_EMOJI/emoji-object-standard-emoji-example) |
1235
-
1236
- #### Message Reaction Remove
1237
-
1238
- Sent when a user removes a reaction from a message.
1239
-
1240
- ###### Message Reaction Remove Event Fields
1241
-
1242
- | Field | Type | Description |
1243
- |------------|--------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------|
1244
- | user_id | snowflake | the id of the user |
1245
- | channel_id | snowflake | the id of the channel |
1246
- | message_id | snowflake | the id of the message |
1247
- | guild_id? | snowflake | the id of the guild |
1248
- | emoji | a partial [emoji](#DOCS_RESOURCES_EMOJI/emoji-object) object | the emoji used to react - [example](#DOCS_RESOURCES_EMOJI/emoji-object-standard-emoji-example) |
1249
-
1250
- #### Message Reaction Remove All
1251
-
1252
- Sent when a user explicitly removes all reactions from a message.
1253
-
1254
- ###### Message Reaction Remove All Event Fields
1255
-
1256
- | Field | Type | Description |
1257
- |------------|-----------|-----------------------|
1258
- | channel_id | snowflake | the id of the channel |
1259
- | message_id | snowflake | the id of the message |
1260
- | guild_id? | snowflake | the id of the guild |
1261
-
1262
- #### Message Reaction Remove Emoji
1263
-
1264
- Sent when a bot removes all instances of a given emoji from the reactions of a message.
1265
-
1266
- ###### Message Reaction Remove Emoji Event Fields
1267
-
1268
- | Field | Type | Description |
1269
- |------------|------------------------------------------------------------|----------------------------|
1270
- | channel_id | snowflake | the id of the channel |
1271
- | guild_id? | snowflake | the id of the guild |
1272
- | message_id | snowflake | the id of the message |
1273
- | emoji | [partial emoji object](#DOCS_RESOURCES_EMOJI/emoji-object) | the emoji that was removed |
1274
-
1275
- ### Presence
1276
-
1277
- #### Presence Update
1278
-
1279
- > warn
1280
- > If you are using [Gateway Intents](#DOCS_TOPICS_GATEWAY/gateway-intents), you _must_ specify the `GUILD_PRESENCES` intent in order to receive Presence Update events
1281
-
1282
- A user's presence is their current state on a guild. This event is sent when a user's presence or info, such as name or avatar, is updated.
1283
-
1284
- > warn
1285
- > The user object within this event can be partial, the only field which must be sent is the `id` field, everything else is optional. Along with this limitation, no fields are required, and the types of the fields are **not** validated. Your client should expect any combination of fields and types within this event.
1286
-
1287
- ###### Presence Update Event Fields
1288
-
1289
- | Field | Type | Description |
1290
- |---------------|-------------------------------------------------------------------|----------------------------------------------|
1291
- | user | [user](#DOCS_RESOURCES_USER/user-object) object | the user presence is being updated for |
1292
- | guild_id | snowflake | id of the guild |
1293
- | status | string | either "idle", "dnd", "online", or "offline" |
1294
- | activities | array of [activity](#DOCS_TOPICS_GATEWAY/activity-object) objects | user's current activities |
1295
- | client_status | [client_status](#DOCS_TOPICS_GATEWAY/client-status-object) object | user's platform-dependent status |
1296
-
1297
- #### Client Status Object
1298
-
1299
- Active sessions are indicated with an "online", "idle", or "dnd" string per platform. If a user is offline or invisible, the corresponding field is not present.
1300
-
1301
- | Field | Type | Description |
1302
- |----------|--------|---------------------------------------------------------------------------------------|
1303
- | desktop? | string | the user's status set for an active desktop (Windows, Linux, Mac) application session |
1304
- | mobile? | string | the user's status set for an active mobile (iOS, Android) application session |
1305
- | web? | string | the user's status set for an active web (browser, bot account) application session |
1306
-
1307
- #### Activity Object
1308
-
1309
- ###### Activity Structure
1310
-
1311
- | Field | Type | Description |
1312
- |-----------------|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
1313
- | name | string | the activity's name |
1314
- | type | integer | [activity type](#DOCS_TOPICS_GATEWAY/activity-object-activity-types) |
1315
- | url? | ?string | stream url, is validated when type is 1 |
1316
- | created_at | integer | unix timestamp (in milliseconds) of when the activity was added to the user's session |
1317
- | timestamps? | [timestamps](#DOCS_TOPICS_GATEWAY/activity-object-activity-timestamps) object | unix timestamps for start and/or end of the game |
1318
- | application_id? | snowflake | application id for the game |
1319
- | details? | ?string | what the player is currently doing |
1320
- | state? | ?string | the user's current party status |
1321
- | emoji? | ?[emoji](#DOCS_TOPICS_GATEWAY/activity-object-activity-emoji) object | the emoji used for a custom status |
1322
- | party? | [party](#DOCS_TOPICS_GATEWAY/activity-object-activity-party) object | information for the current party of the player |
1323
- | assets? | [assets](#DOCS_TOPICS_GATEWAY/activity-object-activity-assets) object | images for the presence and their hover texts |
1324
- | secrets? | [secrets](#DOCS_TOPICS_GATEWAY/activity-object-activity-secrets) object | secrets for Rich Presence joining and spectating |
1325
- | instance? | boolean | whether or not the activity is an instanced game session |
1326
- | flags? | integer | [activity flags](#DOCS_TOPICS_GATEWAY/activity-object-activity-flags) `OR`d together, describes what the payload includes |
1327
- | buttons? | array of [buttons](#DOCS_TOPICS_GATEWAY/activity-object-activity-buttons) | the custom buttons shown in the Rich Presence (max 2) |
1328
-
1329
- > info
1330
- > Bots are only able to send `name`, `type`, and optionally `url`.
1331
-
1332
- ###### Activity Types
1333
-
1334
- | ID | Name | Format | Example |
1335
- |----|-----------|---------------------|--------------------------------------|
1336
- | 0 | Game | Playing {name} | "Playing Rocket League" |
1337
- | 1 | Streaming | Streaming {details} | "Streaming Rocket League" |
1338
- | 2 | Listening | Listening to {name} | "Listening to Spotify" |
1339
- | 3 | Watching | Watching {name} | "Watching YouTube Together" |
1340
- | 4 | Custom | {emoji} {name} | ":smiley: I am cool" |
1341
- | 5 | Competing | Competing in {name} | "Competing in Arena World Champions" |
1342
-
1343
- > info
1344
- > The streaming type currently only supports Twitch and YouTube. Only `https://twitch.tv/` and `https://youtube.com/` urls will work.
1345
-
1346
- ###### Activity Timestamps
1347
-
1348
- | Field | Type | Description |
1349
- |--------|---------|----------------------------------------------------------|
1350
- | start? | integer | unix time (in milliseconds) of when the activity started |
1351
- | end? | integer | unix time (in milliseconds) of when the activity ends |
1352
-
1353
- ###### Activity Emoji
1354
-
1355
- | Field | Type | Description |
1356
- |-----------|-----------|--------------------------------|
1357
- | name | string | the name of the emoji |
1358
- | id? | snowflake | the id of the emoji |
1359
- | animated? | boolean | whether this emoji is animated |
1360
-
1361
- ###### Activity Party
1362
-
1363
- | Field | Type | Description |
1364
- |-------|------------------------------------------------|---------------------------------------------------|
1365
- | id? | string | the id of the party |
1366
- | size? | array of two integers (current_size, max_size) | used to show the party's current and maximum size |
1367
-
1368
- ###### Activity Assets
1369
-
1370
- | Field | Type | Description |
1371
- |--------------|--------|---------------------------------------------------------------------------------------|
1372
- | large_image? | string | see [Activity Asset Image](#DOCS_TOPICS_GATEWAY/activity-object-activity-asset-image) |
1373
- | large_text? | string | text displayed when hovering over the large image of the activity |
1374
- | small_image? | string | see [Activity Asset Image](#DOCS_TOPICS_GATEWAY/activity-object-activity-asset-image) |
1375
- | small_text? | string | text displayed when hovering over the small image of the activity |
1376
-
1377
- ###### Activity Asset Image
1378
-
1379
- Activity asset images are arbitrary strings which usually contain snowflake IDs or prefixed image IDs. Treat data within this field carefully, as it is user-specifiable and not sanitized.
1380
-
1381
- To use an external image via media proxy, specify the URL as the field's value when sending. You will only receive the `mp:` prefix via the gateway.
1382
-
1383
- | Type | Format | Image URL |
1384
- |-------------------|--------------------------|----------------------------------------------------------------------------|
1385
- | Application Asset | `{application_asset_id}` | see [Application Asset Image Formatting](#DOCS_REFERENCE/image-formatting) |
1386
- | Media Proxy Image | `mp:{image_id}` | `https://media.discordapp.net/{image_id}` |
1387
-
1388
- ###### Activity Secrets
1389
-
1390
- | Field | Type | Description |
1391
- |-----------|--------|-------------------------------------------|
1392
- | join? | string | the secret for joining a party |
1393
- | spectate? | string | the secret for spectating a game |
1394
- | match? | string | the secret for a specific instanced match |
1395
-
1396
- ###### Activity Flags
1397
-
1398
- | Name | Value |
1399
- |-----------------------------|--------|
1400
- | INSTANCE | 1 << 0 |
1401
- | JOIN | 1 << 1 |
1402
- | SPECTATE | 1 << 2 |
1403
- | JOIN_REQUEST | 1 << 3 |
1404
- | SYNC | 1 << 4 |
1405
- | PLAY | 1 << 5 |
1406
- | PARTY_PRIVACY_FRIENDS | 1 << 6 |
1407
- | PARTY_PRIVACY_VOICE_CHANNEL | 1 << 7 |
1408
- | EMBEDDED | 1 << 8 |
1409
-
1410
- ###### Activity Buttons
1411
-
1412
- When received over the gateway, the `buttons` field is an array of strings, which are the button labels. Bots cannot access a user's activity button URLs. When sending, the `buttons` field must be an array of the below object:
1413
-
1414
- | Field | Type | Description |
1415
- |-------|--------|------------------------------------------------------------|
1416
- | label | string | the text shown on the button (1-32 characters) |
1417
- | url | string | the url opened when clicking the button (1-512 characters) |
1418
-
1419
- ###### Example Activity
1420
-
1421
- ```json
1422
- {
1423
- "details": "24H RL Stream for Charity",
1424
- "state": "Rocket League",
1425
- "name": "Twitch",
1426
- "type": 1,
1427
- "url": "https://www.twitch.tv/discord"
1428
- }
1429
- ```
1430
-
1431
- ###### Example Activity with Rich Presence
1432
-
1433
- ```json
1434
- {
1435
- "name": "Rocket League",
1436
- "type": 0,
1437
- "application_id": "379286085710381999",
1438
- "state": "In a Match",
1439
- "details": "Ranked Duos: 2-1",
1440
- "timestamps": {
1441
- "start": 15112000660000
1442
- },
1443
- "party": {
1444
- "id": "9dd6594e-81b3-49f6-a6b5-a679e6a060d3",
1445
- "size": [2, 2]
1446
- },
1447
- "assets": {
1448
- "large_image": "351371005538729000",
1449
- "large_text": "DFH Stadium",
1450
- "small_image": "351371005538729111",
1451
- "small_text": "Silver III"
1452
- },
1453
- "secrets": {
1454
- "join": "025ed05c71f639de8bfaa0d679d7c94b2fdce12f",
1455
- "spectate": "e7eb30d2ee025ed05c71ea495f770b76454ee4e0",
1456
- "match": "4b2fdce12f639de8bfa7e3591b71a0d679d7c93f"
1457
- }
1458
- }
1459
- ```
1460
-
1461
- > warn
1462
- > Clients may only update their game status 5 times per 20 seconds.
1463
-
1464
- #### Typing Start
1465
-
1466
- Sent when a user starts typing in a channel.
1467
-
1468
- ###### Typing Start Event Fields
1469
-
1470
- | Field | Type | Description |
1471
- |------------|------------------------------------------------------------|-----------------------------------------------------------|
1472
- | channel_id | snowflake | id of the channel |
1473
- | guild_id? | snowflake | id of the guild |
1474
- | user_id | snowflake | id of the user |
1475
- | timestamp | integer | unix time (in seconds) of when the user started typing |
1476
- | member? | [member](#DOCS_RESOURCES_GUILD/guild-member-object) object | the member who started typing if this happened in a guild |
1477
-
1478
- #### User Update
1479
-
1480
- Sent when properties about the user change. Inner payload is a [user](#DOCS_RESOURCES_USER/user-object) object.
1481
-
1482
- ### Voice
1483
-
1484
- #### Voice State Update
1485
-
1486
- Sent when someone joins/leaves/moves voice channels. Inner payload is a [voice state](#DOCS_RESOURCES_VOICE/voice-state-object) object.
1487
-
1488
- #### Voice Server Update
1489
-
1490
- Sent when a guild's voice server is updated. This is sent when initially connecting to voice, and when the current voice instance fails over to a new server.
1491
-
1492
- > warn
1493
- > A null endpoint means that the voice server allocated has gone away and is trying to be reallocated. You should attempt to disconnect from the currently connected voice server, and not attempt to reconnect until a new voice server is allocated.
1494
-
1495
- ###### Voice Server Update Event Fields
1496
-
1497
- | Field | Type | Description |
1498
- |----------|-----------|-------------------------------------------|
1499
- | token | string | voice connection token |
1500
- | guild_id | snowflake | the guild this voice server update is for |
1501
- | endpoint | ?string | the voice server host |
1502
-
1503
- ###### Example Voice Server Update Payload
1504
-
1505
- ```json
1506
- {
1507
- "token": "my_token",
1508
- "guild_id": "41771983423143937",
1509
- "endpoint": "smart.loyal.discord.gg"
1510
- }
1511
- ```
1512
-
1513
- ### Webhooks
1514
-
1515
- #### Webhooks Update
1516
-
1517
- Sent when a guild channel's webhook is created, updated, or deleted.
1518
-
1519
- ###### Webhooks Update Event Fields
1520
-
1521
- | Field | Type | Description |
1522
- |------------|-----------|-------------------|
1523
- | guild_id | snowflake | id of the guild |
1524
- | channel_id | snowflake | id of the channel |
1525
-
1526
- ### Interactions
1527
-
1528
- #### Interaction Create
1529
-
1530
- Sent when a user in a guild uses an [Application Command](#DOCS_INTERACTIONS_APPLICATION_COMMANDS/). Inner payload is an [Interaction](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-object-interaction-structure).
1531
-
1532
- ### Stage Instances
1533
-
1534
- #### Stage Instance Create
1535
-
1536
- Sent when a [Stage instance](#DOCS_RESOURCES_STAGE_INSTANCE) is created (i.e. the Stage is now "live"). Inner payload is a [Stage instance](#DOCS_RESOURCES_STAGE_INSTANCE/stage-instance-object)
1537
-
1538
- #### Stage Instance Update
1539
-
1540
- Sent when a [Stage instance](#DOCS_RESOURCES_STAGE_INSTANCE) has been updated. Inner payload is a [Stage instance](#DOCS_RESOURCES_STAGE_INSTANCE/stage-instance-object)
1541
-
1542
- #### Stage Instance Delete
1543
-
1544
- Sent when a [Stage instance](#DOCS_RESOURCES_STAGE_INSTANCE) has been deleted (i.e. the Stage has been closed). Inner payload is a [Stage instance](#DOCS_RESOURCES_STAGE_INSTANCE/stage-instance-object)
1545
-
1546
- ## Get Gateway % GET /gateway
1547
-
1548
- > info
1549
- > This endpoint does not require authentication.
1550
-
1551
- Returns an object with a single valid WSS URL, which the client can use for [Connecting](#DOCS_TOPICS_GATEWAY/connecting). Clients **should** cache this value and only call this endpoint to retrieve a new URL if they are unable to properly establish a connection using the cached version of the URL.
1552
-
1553
- ###### Example Response
1554
-
1555
- ```json
1556
- {
1557
- "url": "wss://gateway.discord.gg/"
1558
- }
1559
- ```
1560
-
1561
- ## Get Gateway Bot % GET /gateway/bot
1562
-
1563
- > warn
1564
- > This endpoint requires authentication using a valid bot token.
1565
-
1566
- Returns an object based on the information in [Get Gateway](#DOCS_TOPICS_GATEWAY/get-gateway), plus additional metadata that can help during the operation of large or [sharded](#DOCS_TOPICS_GATEWAY/sharding) bots. Unlike the [Get Gateway](#DOCS_TOPICS_GATEWAY/get-gateway), this route should not be cached for extended periods of time as the value is not guaranteed to be the same per-call, and changes as the bot joins/leaves guilds.
1567
-
1568
- ###### JSON Response
1569
-
1570
- | Field | Type | Description |
1571
- |---------------------|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|
1572
- | url | string | The WSS URL that can be used for connecting to the gateway |
1573
- | shards | integer | The recommended number of [shards](#DOCS_TOPICS_GATEWAY/sharding) to use when connecting |
1574
- | session_start_limit | [session_start_limit](#DOCS_TOPICS_GATEWAY/session-start-limit-object) object | Information on the current session start limit |
1575
-
1576
- ###### Example Response
1577
-
1578
- ```json
1579
- {
1580
- "url": "wss://gateway.discord.gg/",
1581
- "shards": 9,
1582
- "session_start_limit": {
1583
- "total": 1000,
1584
- "remaining": 999,
1585
- "reset_after": 14400000,
1586
- "max_concurrency": 1
1587
- }
1588
- }
1589
- ```
1590
-
1591
- ## Session Start Limit Object
1592
-
1593
- ###### Session Start Limit Structure
1594
-
1595
- | Field | Type | Description |
1596
- | --------------- | ------- | ------------------------------------------------------------------ |
1597
- | total | integer | The total number of session starts the current user is allowed |
1598
- | remaining | integer | The remaining number of session starts the current user is allowed |
1599
- | reset_after | integer | The number of milliseconds after which the limit resets |
1600
- | max_concurrency | integer | The number of identify requests allowed per 5 seconds |