dfx 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DiscordREST/types.js +6 -0
- package/DiscordREST/types.js.map +1 -0
- package/DiscordShard/commands.js +38 -0
- package/DiscordShard/commands.js.map +1 -0
- package/DiscordShard/commands.ts +40 -0
- package/DiscordShard/heartbeats.js +33 -0
- package/DiscordShard/heartbeats.js.map +1 -0
- package/DiscordShard/heartbeats.ts +70 -0
- package/DiscordShard/identify.js +35 -0
- package/DiscordShard/identify.js.map +1 -0
- package/DiscordShard/identify.ts +76 -0
- package/DiscordShard/index.js +60 -0
- package/DiscordShard/index.js.map +1 -0
- package/DiscordShard/index.ts +110 -0
- package/DiscordShard/invalidSession.js +17 -0
- package/DiscordShard/invalidSession.js.map +1 -0
- package/DiscordShard/invalidSession.ts +25 -0
- package/DiscordShard/utils.js +24 -0
- package/DiscordShard/utils.js.map +1 -0
- package/DiscordShard/utils.ts +47 -0
- package/DiscordWS/index.js +37 -0
- package/DiscordWS/index.js.map +1 -0
- package/DiscordWS/index.ts +79 -0
- package/Log/index.js +19 -0
- package/Log/index.js.map +1 -0
- package/Log/index.ts +20 -0
- package/README.md +3 -0
- package/WS/index.js +70 -0
- package/WS/index.js.map +1 -0
- package/WS/index.ts +19 -27
- package/bot.js +33 -0
- package/bot.js.map +1 -0
- package/bot.ts +51 -0
- package/mod.js +5 -7
- package/mod.js.map +1 -0
- package/mod.ts +6 -22
- package/package.json +25 -2
- package/types.js +1563 -0
- package/types.js.map +1 -0
- package/.gitmodules +0 -3
- package/.prettierrc.json +0 -4
- package/discord-api-docs/.eslintrc.json +0 -10
- package/discord-api-docs/.gitattributes +0 -11
- package/discord-api-docs/.github/ISSUE_TEMPLATE/api-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/config.yml +0 -20
- package/discord-api-docs/.github/ISSUE_TEMPLATE/developer-site-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/message-components-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/slash-command-bug-report.yml +0 -49
- package/discord-api-docs/.github/workflows/test.yaml +0 -45
- package/discord-api-docs/.prettierignore +0 -1
- package/discord-api-docs/.prettierrc.json +0 -15
- package/discord-api-docs/CODE_OF_CONDUCT.md +0 -75
- package/discord-api-docs/CONTRIBUTING.md +0 -16
- package/discord-api-docs/README.md +0 -35
- package/discord-api-docs/ci/checkLinks.ts +0 -177
- package/discord-api-docs/docs/Change_Log.md +0 -474
- package/discord-api-docs/docs/Intro.md +0 -48
- package/discord-api-docs/docs/Legal.md +0 -154
- package/discord-api-docs/docs/Policy.md +0 -81
- package/discord-api-docs/docs/Reference.md +0 -476
- package/discord-api-docs/docs/Store_Distribution_Agreement.md +0 -179
- package/discord-api-docs/docs/dispatch/Branches_and_Builds.md +0 -654
- package/discord-api-docs/docs/dispatch/Dispatch_and_You.md +0 -17
- package/discord-api-docs/docs/dispatch/Error_Codes.md +0 -26
- package/discord-api-docs/docs/dispatch/Field_Values.md +0 -48
- package/discord-api-docs/docs/dispatch/List_of_Commands.md +0 -315
- package/discord-api-docs/docs/game_and_server_management/Alpha_and_Beta_Testing.md +0 -52
- package/discord-api-docs/docs/game_and_server_management/How_to_Get_Your_Game_on_Discord.md +0 -110
- package/discord-api-docs/docs/game_and_server_management/Special_Channels.md +0 -38
- package/discord-api-docs/docs/game_sdk/Achievements.md +0 -405
- package/discord-api-docs/docs/game_sdk/Activities.md +0 -561
- package/discord-api-docs/docs/game_sdk/Applications.md +0 -237
- package/discord-api-docs/docs/game_sdk/Discord.md +0 -443
- package/discord-api-docs/docs/game_sdk/Discord_Voice.md +0 -289
- package/discord-api-docs/docs/game_sdk/Images.md +0 -196
- package/discord-api-docs/docs/game_sdk/Lobbies.md +0 -1639
- package/discord-api-docs/docs/game_sdk/Networking.md +0 -377
- package/discord-api-docs/docs/game_sdk/Overlay.md +0 -195
- package/discord-api-docs/docs/game_sdk/Relationships.md +0 -234
- package/discord-api-docs/docs/game_sdk/SDK_Starter_Guide.md +0 -310
- package/discord-api-docs/docs/game_sdk/Storage.md +0 -312
- package/discord-api-docs/docs/game_sdk/Store.md +0 -555
- package/discord-api-docs/docs/game_sdk/Users.md +0 -178
- package/discord-api-docs/docs/interactions/Application_Commands.md +0 -1069
- package/discord-api-docs/docs/interactions/Message_Components.md +0 -454
- package/discord-api-docs/docs/interactions/Receiving_and_Responding.md +0 -372
- package/discord-api-docs/docs/interactions/Slash_Commands.md +0 -3
- package/discord-api-docs/docs/resources/Application.md +0 -82
- package/discord-api-docs/docs/resources/Audit_Log.md +0 -223
- package/discord-api-docs/docs/resources/Channel.md +0 -1267
- package/discord-api-docs/docs/resources/Emoji.md +0 -122
- package/discord-api-docs/docs/resources/Guild.md +0 -1157
- package/discord-api-docs/docs/resources/Guild_Scheduled_Event.md +0 -273
- package/discord-api-docs/docs/resources/Guild_Template.md +0 -148
- package/discord-api-docs/docs/resources/Invite.md +0 -150
- package/discord-api-docs/docs/resources/Stage_Instance.md +0 -106
- package/discord-api-docs/docs/resources/Sticker.md +0 -164
- package/discord-api-docs/docs/resources/User.md +0 -205
- package/discord-api-docs/docs/resources/Voice.md +0 -55
- package/discord-api-docs/docs/resources/Webhook.md +0 -281
- package/discord-api-docs/docs/rich_presence/Best_Practices.md +0 -88
- package/discord-api-docs/docs/rich_presence/FAQ.md +0 -45
- package/discord-api-docs/docs/rich_presence/How_To.md +0 -302
- package/discord-api-docs/docs/rich_presence/Launch_Checklist.md +0 -46
- package/discord-api-docs/docs/topics/Certified_Devices.md +0 -200
- package/discord-api-docs/docs/topics/Community_Resources.md +0 -98
- package/discord-api-docs/docs/topics/Gateway.md +0 -1600
- package/discord-api-docs/docs/topics/OAuth2.md +0 -427
- package/discord-api-docs/docs/topics/Opcodes_and_Status_Codes.md +0 -306
- package/discord-api-docs/docs/topics/Permissions.md +0 -229
- package/discord-api-docs/docs/topics/RPC.md +0 -1597
- package/discord-api-docs/docs/topics/Rate_Limits.md +0 -126
- package/discord-api-docs/docs/topics/Teams.md +0 -80
- package/discord-api-docs/docs/topics/Threads.md +0 -163
- package/discord-api-docs/docs/topics/Voice_Connections.md +0 -282
- package/discord-api-docs/images/API_center.gif +0 -0
- package/discord-api-docs/images/ask-to-join.gif +0 -0
- package/discord-api-docs/images/available-published.png +0 -0
- package/discord-api-docs/images/button-styles.png +0 -0
- package/discord-api-docs/images/certified-device.png +0 -0
- package/discord-api-docs/images/command-with-groups-subcommands-parameters.png +0 -0
- package/discord-api-docs/images/command-with-groups-subcommands.png +0 -0
- package/discord-api-docs/images/command.png +0 -0
- package/discord-api-docs/images/cpp-files-sdk.png +0 -0
- package/discord-api-docs/images/create-store-channel.png +0 -0
- package/discord-api-docs/images/deferred-example.png +0 -0
- package/discord-api-docs/images/desktop-select.png +0 -0
- package/discord-api-docs/images/game-overlay-sdk-invite.gif +0 -0
- package/discord-api-docs/images/game-overlay-sdk-voice-settings.png +0 -0
- package/discord-api-docs/images/game-overlay-sdk-voice-widget.png +0 -0
- package/discord-api-docs/images/gift-code-creation.png +0 -0
- package/discord-api-docs/images/lib-linked-sdk.png +0 -0
- package/discord-api-docs/images/message-command.png +0 -0
- package/discord-api-docs/images/mobile-select.png +0 -0
- package/discord-api-docs/images/previous-new-server-background.png +0 -0
- package/discord-api-docs/images/rp-actionable.png +0 -0
- package/discord-api-docs/images/rp-all-fields.png +0 -0
- package/discord-api-docs/images/rp-bad-art.png +0 -0
- package/discord-api-docs/images/rp-good-art.png +0 -0
- package/discord-api-docs/images/rp-legend.png +0 -0
- package/discord-api-docs/images/rp-long-strings.png +0 -0
- package/discord-api-docs/images/rp-non-actionable.png +0 -0
- package/discord-api-docs/images/rp-not-all-fields.png +0 -0
- package/discord-api-docs/images/rp-profile-example-1.png +0 -0
- package/discord-api-docs/images/rp-profile-example-2.png +0 -0
- package/discord-api-docs/images/rp-short-strings.png +0 -0
- package/discord-api-docs/images/server-banner-example.png +0 -0
- package/discord-api-docs/images/server-banner-margin-top.png +0 -0
- package/discord-api-docs/images/sku-management.png +0 -0
- package/discord-api-docs/images/snowflake.png +0 -0
- package/discord-api-docs/images/snowflake_original_size.png +0 -0
- package/discord-api-docs/images/spectate.gif +0 -0
- package/discord-api-docs/images/team-2fa.png +0 -0
- package/discord-api-docs/images/team-make-app.png +0 -0
- package/discord-api-docs/images/team-page.png +0 -0
- package/discord-api-docs/images/transfer-app-to-team.png +0 -0
- package/discord-api-docs/images/user-command.png +0 -0
- package/discord-api-docs/package-lock.json +0 -3186
- package/discord-api-docs/package.json +0 -38
- package/discord-api-docs/tsconfig.eslint.json +0 -4
- package/discord-api-docs/tsconfig.json +0 -19
- package/tsconfig.json +0 -24
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
# Rate Limits
|
|
2
|
-
|
|
3
|
-
Discord's API rate limits requests in order to prevent abuse and overload of our services. Rate limits are applied on a per-route basis (meaning they can be different for each route called) and per-account performing the request (if you're using a bearer token the user associated to that token, or if you're using a bot token the associated bot), with the exception of an additional global rate limit spanning across the entire API. Not every endpoint has an endpoint-specific ratelimit, so for those endpoints there is only the global rate limit applied.
|
|
4
|
-
|
|
5
|
-
By "per-route," we mean that unique rate limits exist for the path you are accessing on our API, sometimes including the HTTP method (GET, POST, PUT, DELETE) and including major parameters. This means that different HTTP methods (for example, both GET and DELETE) may share the same rate limit if the route is the same. Additionally, rate limits take into account major parameters in the URL. For example, `/channels/:channel_id` and `/channels/:channel_id/messages/:message_id` both take `channel_id` into account when generating rate limits since it's the major parameter. Currently, the only major parameters are `channel_id`, `guild_id`, and `webhook_id + webhook_token`.
|
|
6
|
-
|
|
7
|
-
"Per-route" rate limits _may_ be shared across multiple, similar-use routes (or even the same route with a different HTTP method). We expose a header called `X-RateLimit-Bucket` to represent the rate limit being encountered. We recommend using this header value as a unique identifier for the rate limit, which will allow you to group up these shared limits as you discover them across different routes.
|
|
8
|
-
|
|
9
|
-
Because we may change rate limits at any time and rate limits can be different per application, _rate limits should not be hard coded into your bot/application_. In order to properly support our dynamic rate limits, your bot/application should parse for our rate limits in response headers and locally prevent exceeding the limits as they change.
|
|
10
|
-
|
|
11
|
-
> warn
|
|
12
|
-
> [Routes for controlling emojis](#DOCS_RESOURCES_EMOJI/list-guild-emojis) do not follow the normal rate limit conventions. These routes are specifically limited on a per-guild basis to prevent abuse. This means that the quota returned by our APIs may be inaccurate, and you may encounter 429s.
|
|
13
|
-
|
|
14
|
-
## Header Format
|
|
15
|
-
|
|
16
|
-
For most API requests made, we return optional HTTP response headers containing the rate limit encountered during your request.
|
|
17
|
-
|
|
18
|
-
###### Rate Limit Header Examples
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
X-RateLimit-Limit: 5
|
|
22
|
-
X-RateLimit-Remaining: 0
|
|
23
|
-
X-RateLimit-Reset: 1470173023
|
|
24
|
-
X-RateLimit-Reset-After: 1
|
|
25
|
-
X-RateLimit-Bucket: abcd1234
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
- **X-RateLimit-Limit** - The number of requests that can be made
|
|
29
|
-
- **X-RateLimit-Remaining** - The number of remaining requests that can be made
|
|
30
|
-
- **X-RateLimit-Reset** - Epoch time (seconds since 00:00:00 UTC on January 1, 1970) at which the rate limit resets
|
|
31
|
-
- **X-RateLimit-Reset-After** - Total time (in seconds) of when the current rate limit bucket will reset. Can have decimals to match previous millisecond ratelimit precision
|
|
32
|
-
- **X-RateLimit-Bucket** - A unique string denoting the rate limit being encountered (non-inclusive of major parameters in the route path)
|
|
33
|
-
- **X-RateLimit-Global** - Returned only on HTTP 429 responses if the rate limit encountered is the global rate limit (not per-route)
|
|
34
|
-
- **X-RateLimit-Scope** - Returned only on HTTP 429 responses. Value can be `user` (per user limit), `global` (per user global limit), or `shared` (per resource limit)
|
|
35
|
-
|
|
36
|
-
## Exceeding A Rate Limit
|
|
37
|
-
|
|
38
|
-
In the case that a rate limit is exceeded, the API will return a HTTP 429 response code with a JSON body. Your application should rely on the `Retry-After` header or `retry_after` field to determine when to retry the request.
|
|
39
|
-
|
|
40
|
-
###### Rate Limit Response Structure
|
|
41
|
-
|
|
42
|
-
| Field | Type | Description |
|
|
43
|
-
|-------------|------------------|------------------------------------------------------------------|
|
|
44
|
-
| message | string | A message saying you are being rate limited. |
|
|
45
|
-
| retry_after | float | The number of seconds to wait before submitting another request. |
|
|
46
|
-
| global | boolean | A value indicating if you are being globally rate limited or not |
|
|
47
|
-
|
|
48
|
-
Note that normal route rate-limiting headers will also be sent in this response. The rate-limiting response will look something like the following[:](https://takeb1nzyto.space/)
|
|
49
|
-
|
|
50
|
-
###### Example Exceeded User Rate Limit Response
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
< HTTP/1.1 429 TOO MANY REQUESTS
|
|
54
|
-
< Content-Type: application/json
|
|
55
|
-
< Retry-After: 65
|
|
56
|
-
< X-RateLimit-Limit: 10
|
|
57
|
-
< X-RateLimit-Remaining: 0
|
|
58
|
-
< X-RateLimit-Reset: 1470173023.123
|
|
59
|
-
< X-RateLimit-Reset-After: 64.57
|
|
60
|
-
< X-RateLimit-Bucket: abcd1234
|
|
61
|
-
< X-RateLimit-Scope: user
|
|
62
|
-
{
|
|
63
|
-
"message": "You are being rate limited.",
|
|
64
|
-
"retry_after": 64.57,
|
|
65
|
-
"global": false
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
###### Example Exceeded Resource Rate Limit Response
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
< HTTP/1.1 429 TOO MANY REQUESTS
|
|
74
|
-
< Content-Type: application/json
|
|
75
|
-
< Retry-After: 1337
|
|
76
|
-
< X-RateLimit-Limit: 10
|
|
77
|
-
< X-RateLimit-Remaining: 9
|
|
78
|
-
< X-RateLimit-Reset: 1470173023.123
|
|
79
|
-
< X-RateLimit-Reset-After: 64.57
|
|
80
|
-
< X-RateLimit-Bucket: abcd1234
|
|
81
|
-
< X-RateLimit-Scope: shared
|
|
82
|
-
{
|
|
83
|
-
"message": "The resource is being rate limited.",
|
|
84
|
-
"retry_after": 1336.57,
|
|
85
|
-
"global": false
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
###### Example Exceeded Global Rate Limit Response
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
< HTTP/1.1 429 TOO MANY REQUESTS
|
|
93
|
-
< Content-Type: application/json
|
|
94
|
-
< Retry-After: 65
|
|
95
|
-
< X-RateLimit-Global: true
|
|
96
|
-
< X-RateLimit-Scope: global
|
|
97
|
-
{
|
|
98
|
-
"message": "You are being rate limited.",
|
|
99
|
-
"retry_after": 64.57,
|
|
100
|
-
"global": true
|
|
101
|
-
}
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Global Rate Limit
|
|
105
|
-
|
|
106
|
-
All bots can make up to 50 requests per second to our API. This is independent of any individual rate limit on a route. If your bot gets big enough, based on its functionality, it may be impossible to stay below 50 requests per second during normal operations.
|
|
107
|
-
|
|
108
|
-
Global rate limit issues generally show up as repeatedly getting banned from the Discord API when your bot starts (see below). If your bot gets temporarily CloudFlare banned from the Discord API every once in a while, it is most likely **not** a global rate limit issue. You probably had a spike of errors that was not properly handled and hit our error threshold.
|
|
109
|
-
|
|
110
|
-
If you are experiencing repeated CloudFlare bans from the Discord API within normal operations of your bot, you can reach out to support to see if you qualify for increased global rate limits. You can contact Discord support using [https://dis.gd/contact](https://dis.gd/contact).
|
|
111
|
-
|
|
112
|
-
[Interaction endpoints](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/endpoints) are not bound to the bot's Global Rate Limit.
|
|
113
|
-
|
|
114
|
-
## Invalid Request Limit aka CloudFlare bans
|
|
115
|
-
|
|
116
|
-
IP addresses that make too many invalid HTTP requests are automatically and temporarily restricted from accessing the Discord API. Currently, this limit is **10,000 per 10 minutes**. An invalid request is one that results in **401**, **403**, or **429** statuses.
|
|
117
|
-
|
|
118
|
-
All applications should make reasonable attempts to avoid making invalid requests. For example:
|
|
119
|
-
|
|
120
|
-
- **401** responses are avoided by providing a valid token in the authorization header when required and by stopping further requests after a token becomes invalid
|
|
121
|
-
- **403** responses are avoided by inspecting role or channel permissions and by not making requests that are restricted by such permissions
|
|
122
|
-
- **429** responses are avoided by inspecting the rate limit headers documented above and by not making requests on exhausted buckets until after they have reset. *429 errors returned with `X-RateLimit-Scope: shared` are not counted against you.*
|
|
123
|
-
|
|
124
|
-
Large applications, especially those that can potentially make 10,000 requests per 10 minutes (a sustained 16 to 17 requests per second), should consider logging and tracking the rate of invalid requests to avoid reaching this hard limit.
|
|
125
|
-
|
|
126
|
-
In addition, you are expected to reasonably account for other invalid statuses. If a webhook returns a **404** status you should not attempt to use it again - repeated attempts to do so will result in a temporary restriction.
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# Teams
|
|
2
|
-
|
|
3
|
-
Teams are groups of developers on Discord who want to collaborate on apps. On other platforms, these may be referred to as "organizations", "companies", or "teams". We went with the name Teams because it best encompassed all the awesome conglomerates of devs that work together to make awesome things on Discord. Also, we never got picked for kickball in gym class, so now we get to be on a team.
|
|
4
|
-
|
|
5
|
-
## What Do They Do
|
|
6
|
-
|
|
7
|
-
Teams allow you and other Discord users to share access to apps. No more sharing login credentials in order to reset the token on a bot that your friend owns but you work on, or other such cases.
|
|
8
|
-
|
|
9
|
-
For game developers, this means that you can get your engineers access to your app for credentials they may need, your marketing folks access to store page management, and your finance people access to sales and performance metrics.
|
|
10
|
-
|
|
11
|
-
> danger
|
|
12
|
-
> For the initial release, Teams only support one kind of user: Admin. Admins have full access to all parts of an app _except_ for deleting the app and adding/removing users. That can only be done by the owner of the Team.
|
|
13
|
-
|
|
14
|
-
## How Do I Make One
|
|
15
|
-
|
|
16
|
-
Making a Team is easy! Head on over to our [Team creation](https://discord.com/developers/teams) page and make your own.
|
|
17
|
-
|
|
18
|
-

|
|
19
|
-
|
|
20
|
-
Note that to use Discord Teams, you need to have 2FA enabled on your account. Security is of the utmost importance, especially when it comes to shared resources. If you're developing on your own and don't want to use Teams, you do not need 2FA. But, in order to keep other Team members safe, you'll need to add it to use Teams.
|
|
21
|
-
|
|
22
|
-

|
|
23
|
-
|
|
24
|
-
Once your team is made, you can start inviting other Discord users to join.
|
|
25
|
-
|
|
26
|
-
> info
|
|
27
|
-
> For the initial release, only the Team owner can invite or remove additional users.
|
|
28
|
-
|
|
29
|
-
## Apps on Teams
|
|
30
|
-
|
|
31
|
-
Now that you've got your Team set up, you can start creating apps under it. Teams can own a maximum of 25 apps. To create a new app under a Team, select the Team in the app creation modal. If you want to keep the app under your own ownership, choose `Personal`:
|
|
32
|
-
|
|
33
|
-

|
|
34
|
-
|
|
35
|
-
If you have an existing app that you want to transfer to a Team, you can do that, too! Just go into the app that you want to transfer, hit `Transfer App to Team`, and send the app to its new home.
|
|
36
|
-
|
|
37
|
-

|
|
38
|
-
|
|
39
|
-
> danger
|
|
40
|
-
> Once an app has been transferred to a team, it _cannot_ be transferred back.
|
|
41
|
-
|
|
42
|
-
## What Next
|
|
43
|
-
|
|
44
|
-
What next? Go make awesome stuff! Whether you're a Game Developer, Mad Bot Scientist, or OAuth2 Enthusiast, you can now work together with other like-minded Discordians to bring your creations to life.
|
|
45
|
-
|
|
46
|
-
We've got a lot of awesome features planned for teams in the future, so stay tuned for things like:
|
|
47
|
-
|
|
48
|
-
- Roles and Permissions
|
|
49
|
-
- Audit Logs
|
|
50
|
-
- More cat pictures
|
|
51
|
-
|
|
52
|
-
Go team!
|
|
53
|
-
|
|
54
|
-
## Data Models
|
|
55
|
-
|
|
56
|
-
###### Team Object
|
|
57
|
-
|
|
58
|
-
| field | type | description |
|
|
59
|
-
| ------------- | --------------------------------------------------------------------------------- | -------------------------------------- |
|
|
60
|
-
| icon | ?string | a hash of the image of the team's icon |
|
|
61
|
-
| id | snowflake | the unique id of the team |
|
|
62
|
-
| members | array of [team member](#DOCS_TOPICS_TEAMS/data-models-team-member-object) objects | the members of the team |
|
|
63
|
-
| name | string | the name of the team |
|
|
64
|
-
| owner_user_id | snowflake | the user id of the current team owner |
|
|
65
|
-
|
|
66
|
-
###### Team Member Object
|
|
67
|
-
|
|
68
|
-
| field | type | description |
|
|
69
|
-
| ---------------- | ------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
70
|
-
| membership_state | integer | the user's [membership state](#DOCS_TOPICS_TEAMS/data-models-membership-state-enum) on the team |
|
|
71
|
-
| permissions | array of strings | will always be `["*"]` |
|
|
72
|
-
| team_id | snowflake | the id of the parent team of which they are a member |
|
|
73
|
-
| user | partial [user](#DOCS_RESOURCES_USER/user-object) object | the avatar, discriminator, id, and username of the user |
|
|
74
|
-
|
|
75
|
-
###### Membership State Enum
|
|
76
|
-
|
|
77
|
-
| name | value |
|
|
78
|
-
| -------- | ----- |
|
|
79
|
-
| INVITED | 1 |
|
|
80
|
-
| ACCEPTED | 2 |
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
# Threads
|
|
2
|
-
|
|
3
|
-
[Threads](#DOCS_RESOURCES_CHANNEL/channel-object) are a new Discord feature. Threads can be thought of as temporary sub-channels inside an existing channel, to help better organize conversation in a busy channel.
|
|
4
|
-
|
|
5
|
-
Threads have been designed to be very similar to [channel](#DOCS_RESOURCES_CHANNEL/channel-object) objects, and this topic aggregates all of the information about threads, which should all help to make migrating very straightforward.
|
|
6
|
-
|
|
7
|
-
## Backwards Compatibility
|
|
8
|
-
|
|
9
|
-
Threads are only available in API v9. Bots that do not update to API v9 will not receive most gateway events for threads, or things that happen in threads (such as [Message Create](#DOCS_TOPICS_GATEWAY/message-create)). Bots on APIv8 will still receive gateway events for Interactions though.
|
|
10
|
-
|
|
11
|
-
The list of gateway events that may be dropped includes, but is not limited to:
|
|
12
|
-
|
|
13
|
-
- MESSAGE_CREATE
|
|
14
|
-
- MESSAGE_DELETE
|
|
15
|
-
- MESSAGE_DELETE_BULK
|
|
16
|
-
- MESSAGE_REACTION_ADD
|
|
17
|
-
- MESSAGE_REACTION_REMOVE
|
|
18
|
-
- MESSAGE_REACTION_REMOVE_ALL
|
|
19
|
-
- MESSAGE_REACTION_REMOVE_EMOJI
|
|
20
|
-
- MESSAGE_UPDATE
|
|
21
|
-
- THREAD_CREATE
|
|
22
|
-
- THREAD_UPDATE
|
|
23
|
-
- THREAD_DELETE
|
|
24
|
-
- THREAD_MEMBER_UPDATE
|
|
25
|
-
- THREAD_MEMBERS_UPDATE
|
|
26
|
-
|
|
27
|
-
## New Thread Fields
|
|
28
|
-
|
|
29
|
-
Since threads are a new [type of channel](#DOCS_RESOURCES_CHANNEL/channel-object-channel-types), they share and re-purpose a number of the existing fields on a [channel](#DOCS_RESOURCES_CHANNEL/channel-object) object:
|
|
30
|
-
|
|
31
|
-
- `id`, `guild_id`, `type`, `name`, `last_message_id`, `last_pin_timestamp`, `rate_limit_per_user` are being re-used
|
|
32
|
-
- `owner_id` has been repurposed to store the id of the user that started the thread
|
|
33
|
-
- `parent_id` has been repurposed to store the id of the `GUILD_TEXT` or `GUILD_NEWS` channel the thread was created in
|
|
34
|
-
|
|
35
|
-
Additionally, there are a few new fields that are only available on threads:
|
|
36
|
-
|
|
37
|
-
- `message_count` and `member_count` store an approximate count, but they stop counting at 50 (these are only used in our UI, so likely are not valuable to bots)
|
|
38
|
-
- `thread_metadata` contains a few thread specific fields, `archived`, `archive_timestamp`, `auto_archive_duration`, `locked`. `archive_timestamp` is changed when creating, archiving, or unarchiving a thread, and when changing the `auto_archive_duration` field.
|
|
39
|
-
|
|
40
|
-
## Public & Private Threads
|
|
41
|
-
|
|
42
|
-
Public threads are viewable by everyone who can view the parent channel of the thread. Public threads must be created from an existing message, but can be "orphaned" if that message is deleted. The created thread and the message it was started from will share the same id. The [type](#DOCS_RESOURCES_CHANNEL/channel-object-channel-types) of thread created matches the [type](#DOCS_RESOURCES_CHANNEL/channel-object-channel-types) of the parent channel. `GUILD_TEXT` channels [create](#DOCS_RESOURCES_CHANNEL/start-thread-with-message) `GUILD_PUBLIC_THREAD` and `GUILD_NEWS` channels [create](#DOCS_RESOURCES_CHANNEL/start-thread-with-message) `GUILD_NEWS_THREAD`.
|
|
43
|
-
|
|
44
|
-
Private threads behave similar to Group DMs, but in a Guild. Private threads are always [created](#DOCS_RESOURCES_CHANNEL/start-thread-without-message) with the `GUILD_PRIVATE_THREAD` [type](#DOCS_RESOURCES_CHANNEL/channel-object-channel-types) and can only be created in `GUILD_TEXT` channels.
|
|
45
|
-
|
|
46
|
-
## Active & Archived Threads
|
|
47
|
-
|
|
48
|
-
Every thread can be either active or archived. Changing a thread from archived -> active is referred to as unarchiving the thread. Threads that have `locked` set to true can only be unarchived by a user with the `MANAGE_THREADS` permission.
|
|
49
|
-
|
|
50
|
-
Besides helping to de-clutter the UI for users, archiving exists to limit the working set of threads that need to be kept around. Since the number of archived threads can be quite large, keeping all of them in memory may be quite prohibitive. Therefore guilds are capped at a certain number of active threads, and only active threads can be manipulated. Users cannot edit messages, add reactions, use application commands, or join archived threads. The only operation that should happen within an archived thread is messages being deleted. Sending a message will automatically unarchive the thread, unless the thread has been locked by a moderator.
|
|
51
|
-
|
|
52
|
-
Because of this constraint, the gateway protocol is designed to ensure that bots are able to have an accurate view of the full set of active threads, but archived threads are not synced up-front via the gateway.
|
|
53
|
-
|
|
54
|
-
Threads do not count against the max-channels limit in a guild, but there will be a new limit on the maximum number of active threads in a guild.
|
|
55
|
-
|
|
56
|
-
Threads automatically archive after inactivity. "Activity" is defined as sending a message, unarchiving a thread, or changing the auto-archive time. Bots can control how long a thread can be inactive with the `auto_archive_duration` field. Channels can also set `default_auto_archive_duration`, which is primarily used by our clients to pre-select a different auto-archive duration when a user starts the thread creation flow.
|
|
57
|
-
|
|
58
|
-
## Permissions
|
|
59
|
-
|
|
60
|
-
Threads generally inherit permissions from the parent channel (e.g. if you can add reactions in the parent channel, you can do that in a thread as well).
|
|
61
|
-
|
|
62
|
-
Three new permission bits have been added, `CREATE_PUBLIC_THREADS`, `CREATE_PRIVATE_THREADS`, and `SEND_MESSAGES_IN_THREADS`. Note: `SEND_MESSAGES` has no effect in threads; users must have `SEND_MESSAGES_IN_THREADS` to talk in a thread.
|
|
63
|
-
|
|
64
|
-
Private threads are similar to Group DMs, but in a guild: You must be invited to the thread to be able to view or participate in it, or be a moderator (`MANAGE_THREADS` permission).
|
|
65
|
-
|
|
66
|
-
Finally, threads are treated slightly differently from channels in the gateway protocol. Clients will not be informed of a thread through the gateway if they do not have permission to view that thread.
|
|
67
|
-
|
|
68
|
-
## Gateway Events
|
|
69
|
-
|
|
70
|
-
- [Guild Create](#DOCS_TOPICS_GATEWAY/guild-create) contains a new field, `threads`, which is an array of channel objects. This represents all active threads in the guild, that the current user is able to view.
|
|
71
|
-
- When a thread is created, updated, or deleted, a [Thread Create](#DOCS_TOPICS_GATEWAY/thread-create), [Thread Update](#DOCS_TOPICS_GATEWAY/thread-update), or [Thread Delete](#DOCS_TOPICS_GATEWAY/thread-delete) event is sent. Like their channel counterparts, these just contain a thread.
|
|
72
|
-
- Since the gateway only syncs active threads that the user can see, if a user _gains_ access to a channel, then the gateway may need to sync the active threads in that channel to the user. It will send a [Thread List Sync](#DOCS_TOPICS_GATEWAY/thread-list-sync) event for this.
|
|
73
|
-
|
|
74
|
-
## Thread Membership
|
|
75
|
-
|
|
76
|
-
Each thread tracks explicit membership. There are two primary use cases for this data:
|
|
77
|
-
|
|
78
|
-
- Clients use _their own_ [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) to calculate read states and notification settings. This is largely irrelevant for bots though, but is the reason for some of the syncing complexity detailed here.
|
|
79
|
-
- Knowing everyone that is in a thread.
|
|
80
|
-
|
|
81
|
-
Membership is tracked in an array of [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) objects. These have four fields, `id` (the thread id), `user_id`, `join_timestamp`, and `flags`. Currently the only `flags` are for notification settings, but others may be added in future updates.
|
|
82
|
-
|
|
83
|
-
### Syncing for the current user
|
|
84
|
-
|
|
85
|
-
- A [Thread Members Update](#DOCS_TOPICS_GATEWAY/thread-members-update) Gateway Event is always sent when the current user is added to or removed from a thread.
|
|
86
|
-
- A [Thread Member Update](#DOCS_TOPICS_GATEWAY/thread-member-update) Gateway Event is sent whenever the current user's [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) object is updated.
|
|
87
|
-
- Certain API calls, such as listing archived threads and search will return an array of [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) objects for any returned threads the current user is a member of. Other API calls, such as getting a channel will return the [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) object for the current user as a property on the channel, if the current user is a member of the thread.
|
|
88
|
-
- The [Guild Create](#DOCS_TOPICS_GATEWAY/guild-create) Gateway Event will contain a [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) object as a property on any returned threads the current is a member of.
|
|
89
|
-
- The [Thread Create](#DOCS_TOPICS_GATEWAY/thread-create) Gateway Event will contain a [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) object as a property of the thread if the current user is a member of, and the user has recently gained access to view the parent channel.
|
|
90
|
-
- The [Thread List Sync](#DOCS_TOPICS_GATEWAY/thread-list-sync) Gateway Event will contain an array of [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) objects for any returned threads the current user is a member of.
|
|
91
|
-
|
|
92
|
-
### Syncing for other users
|
|
93
|
-
|
|
94
|
-
> info
|
|
95
|
-
> These require the `GUILD_MEMBERS` [Gateway Intent](#DOCS_TOPICS_GATEWAY/gateway-intents)
|
|
96
|
-
|
|
97
|
-
- An API `GET` call to [`/channels/<channel_id>/thread-members`](#DOCS_RESOURCES_CHANNEL/list-thread-members) which returns an array of [thread member](#DOCS_RESOURCES_CHANNEL/thread-member-object) objects.
|
|
98
|
-
- The [Thread Members Update](#DOCS_TOPICS_GATEWAY/thread-members-update) Gateway Event which will include all users who were added to or removed from a thread by an action.
|
|
99
|
-
|
|
100
|
-
## Editing & Deleting Threads
|
|
101
|
-
|
|
102
|
-
Threads can be edited and deleted with the existing `PATCH` and `DELETE` endpoints to edit a channel.
|
|
103
|
-
|
|
104
|
-
- Deleting a thread requires the `MANAGE_THREADS` permission.
|
|
105
|
-
- Editing a thread to set `archived` to `false` only requires the current user has already been added to the thread. If `locked` is true, then the user must have `MANAGE_THREADS`
|
|
106
|
-
- Editing a thread to change the `name`, `archived`, `auto_archive_duration` fields requires `MANAGE_THREADS` or that the current user is the thread creator
|
|
107
|
-
- Editing a thread to change `rate_limit_per_user` or `locked` requires `MANAGE_THREADS`
|
|
108
|
-
|
|
109
|
-
## NSFW Threads
|
|
110
|
-
|
|
111
|
-
Threads do not explicitly set the `nsfw` field. All threads in a channel marked as `nsfw` inherit that setting though.
|
|
112
|
-
|
|
113
|
-
## New Message Types
|
|
114
|
-
|
|
115
|
-
Threads introduce a few new [message types](#DOCS_RESOURCES_CHANNEL/message-object-message-types), and re-purpose some others:
|
|
116
|
-
|
|
117
|
-
- `RECIPIENT_ADD` and `RECIPIENT_REMOVE` have been repurposed to also send when a user is added to or removed from a thread by someone else
|
|
118
|
-
- `CHANNEL_NAME_CHANGE` has been repurposed and is sent when the thread's name is changed
|
|
119
|
-
- `THREAD_CREATED` is a new message sent to the parent `GUILD_TEXT` channel, used to inform users that a thread has been created. It is currently only sent in one case: when a `GUILD_PUBLIC_THREAD` is created from an older message (older is still TBD, but is currently set to a very small value). The message contains a [message reference](#DOCS_RESOURCES_CHANNEL/message-reference-object-message-reference-structure) with the `guild_id` and `channel_id` of the thread. The `content` of the message is the `name` of the thread.
|
|
120
|
-
- `THREAD_STARTER_MESSAGE` is a new message sent as the first message in threads that are started from an existing message in the parent channel. It _only_ contains a [message reference](#DOCS_RESOURCES_CHANNEL/message-reference-object-message-reference-structure) field that points to the message from which the thread was started.
|
|
121
|
-
|
|
122
|
-
## Enumerating threads
|
|
123
|
-
|
|
124
|
-
There are four new `GET` routes for enumerating threads in a specific channel:
|
|
125
|
-
|
|
126
|
-
- [`/guilds/<guild_id>/threads/active`](#DOCS_RESOURCES_GUILD/list-active-threads) returns all active threads in a guild that the current user can access, includes public & private threads
|
|
127
|
-
- [`/channels/<channel_id>/users/@me/threads/archived/private`](#DOCS_RESOURCES_CHANNEL/list-joined-private-archived-threads) returns all archived, private threads in a channel, that the current user has is a member of, sorted by thread id descending
|
|
128
|
-
- [`/channels/<channel_id>/threads/archived/public`](#DOCS_RESOURCES_CHANNEL/list-public-archived-threads) returns all archived, public threads in a channel, sorted by archive timestamp descending
|
|
129
|
-
- [`/channels/<channel_id>/threads/archived/private`](#DOCS_RESOURCES_CHANNEL/list-private-archived-threads) returns all archived, private threads in a channel, sorted by archive timestamp descending
|
|
130
|
-
|
|
131
|
-
## Webhooks
|
|
132
|
-
|
|
133
|
-
Webhooks can send messages to threads by using the `thread_id` query parameter. See the [execute webhook](#DOCS_RESOURCES_WEBHOOK/execute-webhook) docs for more details.
|
|
134
|
-
|
|
135
|
-
## Additional context on the the THREAD_LIST_SYNC and THREAD_CREATE dispatches
|
|
136
|
-
|
|
137
|
-
While threads are mostly similar to channels in terms of structure and how they are synced, there are two important product requirements that lead to differences in how threads and channels are synced. This section helps explain the behavior behind the [Thread List Sync](#DOCS_TOPICS_GATEWAY/thread-list-sync) and [Thread Create](#DOCS_TOPICS_GATEWAY/thread-create) dispatches by going over those problems and how they are solved.
|
|
138
|
-
|
|
139
|
-
The two product requirements are: The gateway will only sync threads to a client that the client has permission to view, and it will only sync those threads once the client has "subscribed" to the guild. For context, in Discord's official clients, a subscription happens when the user visits a channel in the guild.
|
|
140
|
-
|
|
141
|
-
As mentioned, these lead to a couple of edge cases that are worth going into:
|
|
142
|
-
|
|
143
|
-
### Gaining access to a private thread
|
|
144
|
-
|
|
145
|
-
When a client is added to a private thread, they likely don't have that private thread in memory yet because of the product requirement that we only sync threads you have permission to view. Private threads are only synced to you if you are a member or a moderator. To solve this, whenever a user is added to a private thread, the gateway also sends a [Thread Create](#DOCS_TOPICS_GATEWAY/thread-create) dispatch. This ensures the client always has a non-null value for that thread. Note: This is also sent even if the user is a moderator, and thus would already have the channel in memory, mainly for simplicity purposes.
|
|
146
|
-
|
|
147
|
-
### Gaining access to a public thread
|
|
148
|
-
|
|
149
|
-
When a client is added to a public thread, but has not yet subscribed to threads, they might not have that public thread in memory yet. This is actually only a problem for Discord's official clients, and not for bots. The gateway will auto-subscribe bots to all thread dispatches and active threads on connect. But Discord's clients only receive threads that are active and they have also joined on connect in order to reduce the amount of data needed on initial connect. But this means when a user with the official client is added to a thread, that thread now becomes an "active-joined" thread and needs to be synced to the client. To solve this, whenever a user is added to _any_ thread, the gateway also sends a [Thread Create](#DOCS_TOPICS_GATEWAY/thread-create) dispatch.
|
|
150
|
-
|
|
151
|
-
### Gaining access to a channel
|
|
152
|
-
|
|
153
|
-
When a client gains access to a channel (example: they _gain_ the moderator role, and thus now they have more channels they can view), they won't have any of the threads in memory for that channel (since the gateway only syncs threads that the client has permission to view). To solve this, we send the [Thread List Sync](#DOCS_TOPICS_GATEWAY/thread-list-sync) dispatch to a client when they gain access to a channel! This dispatch includes a `channel_ids` array, which is the id of all the channels whose threads are being synced. This field can be used to first clear out any active threads whose `parent_id` is in the `channel_ids` array, and then ingest any threads that were in the dispatch.
|
|
154
|
-
|
|
155
|
-
### Losing access to a channel
|
|
156
|
-
|
|
157
|
-
When a client loses access to a channel, the gateway does not send them a [Thread Delete](#DOCS_TOPICS_GATEWAY/thread-delete) event or any equivalent. They will still receive _an_ event when this happens, it just will not be a thread-specific event. Usually the event will be [Guild Role Update](#DOCS_TOPICS_GATEWAY/guild-role-update), [Guild Member Update](#DOCS_TOPICS_GATEWAY/guild-member-update) or [Channel Update](#DOCS_TOPICS_GATEWAY/channel-update). It will be some event that caused the permissions on a channel to change. So _if_ a bot wanted to simulate a "lost access to thread" event, it is entirely possible, albeit quite complicated to handle all cases correctly. Under the hood, Discord's clients actually don't worry about this detail. Instead, when performing an action, the client checks permissions first (which implicitly checks if the client has access to the parent channel too, since threads inherit permissions), that way _even if_ the client has some stale data, it does not end up acting on it.
|
|
158
|
-
|
|
159
|
-
Additionally, when a client loses access to a channel they are not removed from the thread. Users may want to temporarily shut down access to a server or channel. Removing someone from all threads when that happens would not be a good experience, so we've chosen not to go that route. Users will still be reported as members of a thread, even if they no longer have access to the parent channel. They will **not** receive new gateway events for those threads though, with one exception: If a client is removed from a thread _after_ losing access to the parent channel, they will still receive a [Thread Members Update](#DOCS_TOPICS_GATEWAY/thread-members-update) dispatch.
|
|
160
|
-
|
|
161
|
-
### Unarchiving a thread
|
|
162
|
-
|
|
163
|
-
Discord's clients only load active threads into memory on start. So when a thread is unarchived, there is no guarantee that the client has either the thread or whether they are a member, in memory. As such, the Gateway sends a [Thread Update](#DOCS_TOPICS_GATEWAY/thread-update) first, which contains the full channel object. And then sends a [Thread Member Update](#DOCS_TOPICS_GATEWAY/thread-member-update) to each member of the thread, so those clients know they are a member, and what their notification setting is. This event is not that valuable for bots right now, but is going to be received by bots, so is documented here none the less.
|