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.
Files changed (162) hide show
  1. package/DiscordREST/types.js +6 -0
  2. package/DiscordREST/types.js.map +1 -0
  3. package/DiscordShard/commands.js +38 -0
  4. package/DiscordShard/commands.js.map +1 -0
  5. package/DiscordShard/commands.ts +40 -0
  6. package/DiscordShard/heartbeats.js +33 -0
  7. package/DiscordShard/heartbeats.js.map +1 -0
  8. package/DiscordShard/heartbeats.ts +70 -0
  9. package/DiscordShard/identify.js +35 -0
  10. package/DiscordShard/identify.js.map +1 -0
  11. package/DiscordShard/identify.ts +76 -0
  12. package/DiscordShard/index.js +60 -0
  13. package/DiscordShard/index.js.map +1 -0
  14. package/DiscordShard/index.ts +110 -0
  15. package/DiscordShard/invalidSession.js +17 -0
  16. package/DiscordShard/invalidSession.js.map +1 -0
  17. package/DiscordShard/invalidSession.ts +25 -0
  18. package/DiscordShard/utils.js +24 -0
  19. package/DiscordShard/utils.js.map +1 -0
  20. package/DiscordShard/utils.ts +47 -0
  21. package/DiscordWS/index.js +37 -0
  22. package/DiscordWS/index.js.map +1 -0
  23. package/DiscordWS/index.ts +79 -0
  24. package/Log/index.js +19 -0
  25. package/Log/index.js.map +1 -0
  26. package/Log/index.ts +20 -0
  27. package/README.md +3 -0
  28. package/WS/index.js +70 -0
  29. package/WS/index.js.map +1 -0
  30. package/WS/index.ts +19 -27
  31. package/bot.js +33 -0
  32. package/bot.js.map +1 -0
  33. package/bot.ts +51 -0
  34. package/mod.js +5 -7
  35. package/mod.js.map +1 -0
  36. package/mod.ts +6 -22
  37. package/package.json +25 -2
  38. package/types.js +1563 -0
  39. package/types.js.map +1 -0
  40. package/.gitmodules +0 -3
  41. package/.prettierrc.json +0 -4
  42. package/discord-api-docs/.eslintrc.json +0 -10
  43. package/discord-api-docs/.gitattributes +0 -11
  44. package/discord-api-docs/.github/ISSUE_TEMPLATE/api-bug-report.yml +0 -49
  45. package/discord-api-docs/.github/ISSUE_TEMPLATE/config.yml +0 -20
  46. package/discord-api-docs/.github/ISSUE_TEMPLATE/developer-site-bug-report.yml +0 -49
  47. package/discord-api-docs/.github/ISSUE_TEMPLATE/message-components-bug-report.yml +0 -49
  48. package/discord-api-docs/.github/ISSUE_TEMPLATE/slash-command-bug-report.yml +0 -49
  49. package/discord-api-docs/.github/workflows/test.yaml +0 -45
  50. package/discord-api-docs/.prettierignore +0 -1
  51. package/discord-api-docs/.prettierrc.json +0 -15
  52. package/discord-api-docs/CODE_OF_CONDUCT.md +0 -75
  53. package/discord-api-docs/CONTRIBUTING.md +0 -16
  54. package/discord-api-docs/README.md +0 -35
  55. package/discord-api-docs/ci/checkLinks.ts +0 -177
  56. package/discord-api-docs/docs/Change_Log.md +0 -474
  57. package/discord-api-docs/docs/Intro.md +0 -48
  58. package/discord-api-docs/docs/Legal.md +0 -154
  59. package/discord-api-docs/docs/Policy.md +0 -81
  60. package/discord-api-docs/docs/Reference.md +0 -476
  61. package/discord-api-docs/docs/Store_Distribution_Agreement.md +0 -179
  62. package/discord-api-docs/docs/dispatch/Branches_and_Builds.md +0 -654
  63. package/discord-api-docs/docs/dispatch/Dispatch_and_You.md +0 -17
  64. package/discord-api-docs/docs/dispatch/Error_Codes.md +0 -26
  65. package/discord-api-docs/docs/dispatch/Field_Values.md +0 -48
  66. package/discord-api-docs/docs/dispatch/List_of_Commands.md +0 -315
  67. package/discord-api-docs/docs/game_and_server_management/Alpha_and_Beta_Testing.md +0 -52
  68. package/discord-api-docs/docs/game_and_server_management/How_to_Get_Your_Game_on_Discord.md +0 -110
  69. package/discord-api-docs/docs/game_and_server_management/Special_Channels.md +0 -38
  70. package/discord-api-docs/docs/game_sdk/Achievements.md +0 -405
  71. package/discord-api-docs/docs/game_sdk/Activities.md +0 -561
  72. package/discord-api-docs/docs/game_sdk/Applications.md +0 -237
  73. package/discord-api-docs/docs/game_sdk/Discord.md +0 -443
  74. package/discord-api-docs/docs/game_sdk/Discord_Voice.md +0 -289
  75. package/discord-api-docs/docs/game_sdk/Images.md +0 -196
  76. package/discord-api-docs/docs/game_sdk/Lobbies.md +0 -1639
  77. package/discord-api-docs/docs/game_sdk/Networking.md +0 -377
  78. package/discord-api-docs/docs/game_sdk/Overlay.md +0 -195
  79. package/discord-api-docs/docs/game_sdk/Relationships.md +0 -234
  80. package/discord-api-docs/docs/game_sdk/SDK_Starter_Guide.md +0 -310
  81. package/discord-api-docs/docs/game_sdk/Storage.md +0 -312
  82. package/discord-api-docs/docs/game_sdk/Store.md +0 -555
  83. package/discord-api-docs/docs/game_sdk/Users.md +0 -178
  84. package/discord-api-docs/docs/interactions/Application_Commands.md +0 -1069
  85. package/discord-api-docs/docs/interactions/Message_Components.md +0 -454
  86. package/discord-api-docs/docs/interactions/Receiving_and_Responding.md +0 -372
  87. package/discord-api-docs/docs/interactions/Slash_Commands.md +0 -3
  88. package/discord-api-docs/docs/resources/Application.md +0 -82
  89. package/discord-api-docs/docs/resources/Audit_Log.md +0 -223
  90. package/discord-api-docs/docs/resources/Channel.md +0 -1267
  91. package/discord-api-docs/docs/resources/Emoji.md +0 -122
  92. package/discord-api-docs/docs/resources/Guild.md +0 -1157
  93. package/discord-api-docs/docs/resources/Guild_Scheduled_Event.md +0 -273
  94. package/discord-api-docs/docs/resources/Guild_Template.md +0 -148
  95. package/discord-api-docs/docs/resources/Invite.md +0 -150
  96. package/discord-api-docs/docs/resources/Stage_Instance.md +0 -106
  97. package/discord-api-docs/docs/resources/Sticker.md +0 -164
  98. package/discord-api-docs/docs/resources/User.md +0 -205
  99. package/discord-api-docs/docs/resources/Voice.md +0 -55
  100. package/discord-api-docs/docs/resources/Webhook.md +0 -281
  101. package/discord-api-docs/docs/rich_presence/Best_Practices.md +0 -88
  102. package/discord-api-docs/docs/rich_presence/FAQ.md +0 -45
  103. package/discord-api-docs/docs/rich_presence/How_To.md +0 -302
  104. package/discord-api-docs/docs/rich_presence/Launch_Checklist.md +0 -46
  105. package/discord-api-docs/docs/topics/Certified_Devices.md +0 -200
  106. package/discord-api-docs/docs/topics/Community_Resources.md +0 -98
  107. package/discord-api-docs/docs/topics/Gateway.md +0 -1600
  108. package/discord-api-docs/docs/topics/OAuth2.md +0 -427
  109. package/discord-api-docs/docs/topics/Opcodes_and_Status_Codes.md +0 -306
  110. package/discord-api-docs/docs/topics/Permissions.md +0 -229
  111. package/discord-api-docs/docs/topics/RPC.md +0 -1597
  112. package/discord-api-docs/docs/topics/Rate_Limits.md +0 -126
  113. package/discord-api-docs/docs/topics/Teams.md +0 -80
  114. package/discord-api-docs/docs/topics/Threads.md +0 -163
  115. package/discord-api-docs/docs/topics/Voice_Connections.md +0 -282
  116. package/discord-api-docs/images/API_center.gif +0 -0
  117. package/discord-api-docs/images/ask-to-join.gif +0 -0
  118. package/discord-api-docs/images/available-published.png +0 -0
  119. package/discord-api-docs/images/button-styles.png +0 -0
  120. package/discord-api-docs/images/certified-device.png +0 -0
  121. package/discord-api-docs/images/command-with-groups-subcommands-parameters.png +0 -0
  122. package/discord-api-docs/images/command-with-groups-subcommands.png +0 -0
  123. package/discord-api-docs/images/command.png +0 -0
  124. package/discord-api-docs/images/cpp-files-sdk.png +0 -0
  125. package/discord-api-docs/images/create-store-channel.png +0 -0
  126. package/discord-api-docs/images/deferred-example.png +0 -0
  127. package/discord-api-docs/images/desktop-select.png +0 -0
  128. package/discord-api-docs/images/game-overlay-sdk-invite.gif +0 -0
  129. package/discord-api-docs/images/game-overlay-sdk-voice-settings.png +0 -0
  130. package/discord-api-docs/images/game-overlay-sdk-voice-widget.png +0 -0
  131. package/discord-api-docs/images/gift-code-creation.png +0 -0
  132. package/discord-api-docs/images/lib-linked-sdk.png +0 -0
  133. package/discord-api-docs/images/message-command.png +0 -0
  134. package/discord-api-docs/images/mobile-select.png +0 -0
  135. package/discord-api-docs/images/previous-new-server-background.png +0 -0
  136. package/discord-api-docs/images/rp-actionable.png +0 -0
  137. package/discord-api-docs/images/rp-all-fields.png +0 -0
  138. package/discord-api-docs/images/rp-bad-art.png +0 -0
  139. package/discord-api-docs/images/rp-good-art.png +0 -0
  140. package/discord-api-docs/images/rp-legend.png +0 -0
  141. package/discord-api-docs/images/rp-long-strings.png +0 -0
  142. package/discord-api-docs/images/rp-non-actionable.png +0 -0
  143. package/discord-api-docs/images/rp-not-all-fields.png +0 -0
  144. package/discord-api-docs/images/rp-profile-example-1.png +0 -0
  145. package/discord-api-docs/images/rp-profile-example-2.png +0 -0
  146. package/discord-api-docs/images/rp-short-strings.png +0 -0
  147. package/discord-api-docs/images/server-banner-example.png +0 -0
  148. package/discord-api-docs/images/server-banner-margin-top.png +0 -0
  149. package/discord-api-docs/images/sku-management.png +0 -0
  150. package/discord-api-docs/images/snowflake.png +0 -0
  151. package/discord-api-docs/images/snowflake_original_size.png +0 -0
  152. package/discord-api-docs/images/spectate.gif +0 -0
  153. package/discord-api-docs/images/team-2fa.png +0 -0
  154. package/discord-api-docs/images/team-make-app.png +0 -0
  155. package/discord-api-docs/images/team-page.png +0 -0
  156. package/discord-api-docs/images/transfer-app-to-team.png +0 -0
  157. package/discord-api-docs/images/user-command.png +0 -0
  158. package/discord-api-docs/package-lock.json +0 -3186
  159. package/discord-api-docs/package.json +0 -38
  160. package/discord-api-docs/tsconfig.eslint.json +0 -4
  161. package/discord-api-docs/tsconfig.json +0 -19
  162. package/tsconfig.json +0 -24
@@ -1,476 +0,0 @@
1
- # API Reference
2
-
3
- Discord's API is based around two core layers, a HTTPS/REST API for general operations, and persistent secure WebSocket based connection for sending and subscribing to real-time events. The most common use case of the Discord API will be providing a service, or access to a platform through the [OAuth2](https://oauth.net/2/) API.
4
-
5
- ###### Base URL
6
-
7
- ```
8
- https://discord.com/api
9
- ```
10
-
11
- ## API Versioning
12
-
13
- > danger
14
- > Some API and Gateway versions are now non-functioning, and are labeled as discontinued in the table below for posterity. Trying to use these versions will fail and return 400 Bad Request.
15
-
16
- Discord exposes different versions of our API. You can specify which version to use by including it in the request path like `https://discord.com/api/v{version_number}`. Omitting the version number from the route will route requests to the current default version (marked below accordingly). You can find the change log for the newest API version [here](https://discord.com/developers/docs/change-log).
17
-
18
- ###### API Versions
19
-
20
- | Version | Status | Default |
21
- |---------|----------------------------------|---------|
22
- | 9 | Available | |
23
- | 8 | Available | |
24
- | 7 | Doesn't look like anything to me | |
25
- | 6 | Deprecated | ✓ |
26
- | 5 | Discontinued | |
27
- | 4 | Discontinued | |
28
- | 3 | Discontinued | |
29
-
30
- ## Error Messages
31
-
32
- In API v8, we've improved error formatting in form error responses. The response will tell you which json key contains the error, the error code, and a human readable error message. We will be frequently adding new error messages, so a complete list of errors is not feasible and would be almost instantly out of date. Here are some examples instead:
33
-
34
- ###### Array Error
35
-
36
- ```json
37
- {
38
- "code": 50035,
39
- "errors": {
40
- "activities": {
41
- "0": {
42
- "platform": {
43
- "_errors": [
44
- {
45
- "code": "BASE_TYPE_CHOICES",
46
- "message": "Value must be one of ('desktop', 'android', 'ios')."
47
- }
48
- ]
49
- },
50
- "type": {
51
- "_errors": [
52
- {
53
- "code": "BASE_TYPE_CHOICES",
54
- "message": "Value must be one of (0, 1, 2, 3, 4, 5)."
55
- }
56
- ]
57
- }
58
- }
59
- }
60
- },
61
- "message": "Invalid Form Body"
62
- }
63
- ```
64
-
65
- ###### Object Error
66
-
67
- ```json
68
- {
69
- "code": 50035,
70
- "errors": {
71
- "access_token": {
72
- "_errors": [
73
- {
74
- "code": "BASE_TYPE_REQUIRED",
75
- "message": "This field is required"
76
- }
77
- ]
78
- }
79
- },
80
- "message": "Invalid Form Body"
81
- }
82
- ```
83
-
84
- ###### Request Error
85
-
86
- ```json
87
- {
88
- "code": 50035,
89
- "message": "Invalid Form Body",
90
- "errors": {
91
- "_errors": [
92
- {
93
- "code": "APPLICATION_COMMAND_TOO_LARGE",
94
- "message": "Command exceeds maximum size (4000)"
95
- }
96
- ]
97
- }
98
- }
99
- ```
100
-
101
- ## Authentication
102
-
103
- Authenticating with the Discord API can be done in one of two ways:
104
-
105
- 1. Using a bot token gained by [registering a bot](#APPLICATIONS), for more information on bots see [bots vs user accounts](#DOCS_TOPICS_OAUTH2/bot-vs-user-accounts).
106
- 2. Using an OAuth2 bearer token gained through the [OAuth2 API](#DOCS_TOPICS_OAUTH2/oauth2).
107
-
108
- For all authentication types, authentication is performed with the `Authorization` HTTP header in the format `Authorization: TOKEN_TYPE TOKEN`.
109
-
110
- ###### Example Bot Token Authorization Header
111
-
112
- ```
113
- Authorization: Bot MTk4NjIyNDgzNDcxOTI1MjQ4.Cl2FMQ.ZnCjm1XVW7vRze4b7Cq4se7kKWs
114
- ```
115
-
116
- ###### Example Bearer Token Authorization Header
117
-
118
- ```
119
- Authorization: Bearer CZhtkLDpNYXgPH9Ml6shqh2OwykChw
120
- ```
121
-
122
- ## Encryption
123
-
124
- All HTTP-layer services and protocols (e.g. HTTP, WebSocket) within the Discord API are using TLS 1.2.
125
-
126
- ## Snowflakes
127
-
128
- Discord utilizes Twitter's [snowflake](https://github.com/twitter/snowflake/tree/snowflake-2010) format for uniquely identifiable descriptors (IDs). These IDs are guaranteed to be unique across all of Discord, except in some unique scenarios in which child objects share their parent's ID. Because Snowflake IDs are up to 64 bits in size (e.g. a uint64), they are always returned as strings in the HTTP API to prevent integer overflows in some languages. See [Gateway ETF/JSON](#DOCS_TOPICS_GATEWAY/etfjson) for more information regarding Gateway encoding.
129
-
130
- ###### Snowflake ID Broken Down in Binary
131
-
132
- ```
133
- 111111111111111111111111111111111111111111 11111 11111 111111111111
134
- 64 22 17 12 0
135
- ```
136
-
137
- ###### Snowflake ID Format Structure (Left to Right)
138
-
139
- | Field | Bits | Number of bits | Description | Retrieval |
140
- |---------------------|----------|----------------|------------------------------------------------------------------------------|-------------------------------------|
141
- | Timestamp | 63 to 22 | 42 bits | Milliseconds since Discord Epoch, the first second of 2015 or 1420070400000. | `(snowflake >> 22) + 1420070400000` |
142
- | Internal worker ID | 21 to 17 | 5 bits | | `(snowflake & 0x3E0000) >> 17` |
143
- | Internal process ID | 16 to 12 | 5 bits | | `(snowflake & 0x1F000) >> 12` |
144
- | Increment | 11 to 0 | 12 bits | For every ID that is generated on that process, this number is incremented | `snowflake & 0xFFF` |
145
-
146
- ### Convert Snowflake to DateTime
147
-
148
- ![Graphical representation of how a Snowflake is constructed](snowflake.png)
149
-
150
- ### Snowflake IDs in Pagination
151
-
152
- We typically use snowflake IDs in many of our API routes for pagination. The standardized pagination paradigm we utilize is one in which you can specify IDs `before` and `after` in combination with `limit` to retrieve a desired page of results. You will want to refer to the specific endpoint documentation for details.
153
-
154
- It is useful to note that snowflake IDs are just numbers with a timestamp, so when dealing with pagination where you want results from the beginning of time (in Discord Epoch, but `0` works here too) or before/after a specific time you can generate a snowflake ID for that time.
155
-
156
- ###### Generating a snowflake ID from a Timestamp Example
157
-
158
- ```
159
- (timestamp_ms - DISCORD_EPOCH) << 22
160
- ```
161
-
162
- ## ID Serialization
163
-
164
- There are some cases in which our API and Gateway may return IDs in an unexpected format. Internally, Discord stores IDs as integer snowflakes. When we serialize IDs to JSON, we transform `bigints` into strings. Given that all Discord IDs are snowflakes, you should always expect a string.
165
-
166
- However, there are cases in which passing something to our API will instead return IDs serialized as an integer; this is the case when you send our API or Gateway a value in an `id` field that is not `bigint` size. For example, when requesting `GUILD_MEMBERS_CHUNK` from our gateway:
167
-
168
- ```
169
- // Send
170
- {
171
- op: 8,
172
- d: {
173
- guild_id: '308994132968210433',
174
- user_ids: [ '123123' ]
175
- }
176
- }
177
-
178
- // Receive
179
- {
180
- t: 'GUILD_MEMBERS_CHUNK',
181
- s: 3,
182
- op: 0,
183
- d: {
184
- not_found: [ 123123 ],
185
- members: [],
186
- guild_id: '308994132968210433'
187
- }
188
- }
189
- ```
190
-
191
- You can see in this case that the sent `user_id` is not a `bigint`; therefore, when it is serialized back to JSON by Discord, it is not transformed into a string. **This will never happen with IDs that come from Discord.** But, this can happen if you send malformed data in your requests.
192
-
193
- ## ISO8601 Date/Time
194
-
195
- Discord utilizes the [ISO8601 format](https://www.loc.gov/standards/datetime/iso-tc154-wg5_n0038_iso_wd_8601-1_2016-02-16.pdf) for most Date/Times returned in our models. This format is referred to as type `ISO8601` within tables in this documentation.
196
-
197
- ## Nullable and Optional Resource Fields
198
-
199
- Resource fields that may contain a `null` value have types that are prefixed with a question mark.
200
- Resource fields that are optional have names that are suffixed with a question mark.
201
-
202
- ###### Example Nullable and Optional Fields
203
-
204
- | Field | Type |
205
- |------------------------------|---------|
206
- | optional_field? | string |
207
- | nullable_field | ?string |
208
- | optional_and_nullable_field? | ?string |
209
-
210
- ## Consistency
211
-
212
- Discord operates at a scale where true consistency is impossible. Because of this, lots of operations in our API and in-between our services are [eventually consistent](https://en.wikipedia.org/wiki/Eventual_consistency). Due to this, client actions can never be serialized and may be executed in _any_ order (if executed at all). Along with these constraints, events in Discord may:
213
-
214
- - Never be sent to a client
215
- - Be sent _exactly_ one time to the client
216
- - Be sent up to N times per client
217
-
218
- Clients should operate on events and results from the API in as much of an idempotent behavior as possible.
219
-
220
- ## HTTP API
221
-
222
- ### User Agent
223
-
224
- Clients using the HTTP API must provide a valid [User Agent](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43) which specifies information about the client library and version in the following format:
225
-
226
- ###### User Agent Example
227
-
228
- ```
229
- User-Agent: DiscordBot ($url, $versionNumber)
230
- ```
231
-
232
- Clients may append more information and metadata to the _end_ of this string as they wish.
233
-
234
- ### Rate Limiting
235
-
236
- The HTTP API implements a process for limiting and preventing excessive requests in accordance with [RFC 6585](https://tools.ietf.org/html/rfc6585#section-4). API users that regularly hit and ignore rate limits will have their API keys revoked, and be blocked from the platform. For more information on rate limiting of requests, please see the [Rate Limits](#DOCS_TOPICS_RATE_LIMITS/rate-limits) section.
237
-
238
- ### Boolean Query Strings
239
-
240
- Certain endpoints in the API are documented to accept booleans for their query string parameters. While there is no standard system for boolean representation in query string parameters, Discord represents such cases using `True`, `true`, or `1` for true and `False`, `false` or `0` for false.
241
-
242
- ## Gateway (WebSocket) API
243
-
244
- Discord's Gateway API is used for maintaining persistent, stateful websocket connections between your client and our servers. These connections are used for sending and receiving real-time events your client can use to track and update local state. The Gateway API uses secure websocket connections as specified in [RFC 6455](https://tools.ietf.org/html/rfc6455). For information on opening Gateway connections, please see the [Gateway API](#DOCS_TOPICS_GATEWAY/gateways) section.
245
-
246
- ## Message Formatting
247
-
248
- Discord utilizes a subset of markdown for rendering message content on its clients, while also adding some custom functionality to enable things like mentioning users and channels. This functionality uses the following formats:
249
-
250
- ###### Formats
251
-
252
- | Type | Structure | Example |
253
- |-------------------------|---------------------|------------------------------|
254
- | User | <@USER_ID> | <@80351110224678912> |
255
- | User (Nickname) | <@!USER_ID> | <@!80351110224678912> |
256
- | Channel | <#CHANNEL_ID> | <#103735883630395392> |
257
- | Role | <@&ROLE_ID> | <@&165511591545143296> |
258
- | Standard Emoji | Unicode Characters | 💯 |
259
- | Custom Emoji | <:NAME:ID> | <:mmLol:216154654256398347> |
260
- | Custom Emoji (Animated) | <a:NAME:ID> | <a:b1nzy:392938283556143104> |
261
- | Unix Timestamp | <t:TIMESTAMP> | <t:1618953630> |
262
- | Unix Timestamp (Styled) | <t:TIMESTAMP:STYLE> | <t:1618953630:d> |
263
-
264
- Using the markdown for either users, roles, or channels will usually mention the target(s) accordingly, but this can be suppressed using the `allowed_mentions` parameter when creating a message. Standard emoji are currently rendered using [Twemoji](https://twemoji.twitter.com/) for Desktop/Android and Apple's native emoji on iOS.
265
-
266
- Timestamps will display the given timestamp in the user's timezone and locale.
267
-
268
- ###### Timestamp Styles
269
-
270
- | Style | Example Output | Description |
271
- | ----- | ---------------------------- | --------------- |
272
- | t | 16:20 | Short Time |
273
- | T | 16:20:30 | Long Time |
274
- | d | 20/04/2021 | Short Date |
275
- | D | 20 April 2021 | Long Date |
276
- | f \* | 20 April 2021 16:20 | Short Date/Time |
277
- | F | Tuesday, 20 April 2021 16:20 | Long Date/Time |
278
- | R | 2 months ago | Relative Time |
279
-
280
- \*default
281
-
282
- ## Image Formatting
283
-
284
- ###### Image Base Url
285
-
286
- ```
287
- https://cdn.discordapp.com/
288
- ```
289
-
290
- Discord uses ids and hashes to render images in the client. These hashes can be retrieved through various API requests, like [Get User](#DOCS_RESOURCES_USER/get-user). Below are the formats, size limitations, and CDN endpoints for images in Discord. The returned format can be changed by changing the [extension name](#DOCS_REFERENCE/image-formatting-image-formats) at the end of the URL. The returned size can be changed by appending a querystring of `?size=desired_size` to the URL. Image size can be any power of two between 16 and 4096.
291
-
292
- ###### Image Formats
293
-
294
- | Name | Extension |
295
- |--------|-------------|
296
- | JPEG | .jpg, .jpeg |
297
- | PNG | .png |
298
- | WebP | .webp |
299
- | GIF | .gif |
300
- | Lottie | .json |
301
-
302
- ###### CDN Endpoints
303
-
304
- | Type | Path | Supports |
305
- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
306
- | Custom Emoji | emojis/[emoji_id](#DOCS_RESOURCES_EMOJI/emoji-object).png | PNG, JPEG, WebP, GIF |
307
- | Guild Icon | icons/[guild_id](#DOCS_RESOURCES_GUILD/guild-object)/[guild_icon](#DOCS_RESOURCES_GUILD/guild-object).png \* | PNG, JPEG, WebP, GIF |
308
- | Guild Splash | splashes/[guild_id](#DOCS_RESOURCES_GUILD/guild-object)/[guild_splash](#DOCS_RESOURCES_GUILD/guild-object).png | PNG, JPEG, WebP |
309
- | Guild Discovery Splash | discovery-splashes/[guild_id](#DOCS_RESOURCES_GUILD/guild-object)/[guild_discovery_splash](#DOCS_RESOURCES_GUILD/guild-object).png | PNG, JPEG, WebP |
310
- | Guild Banner | banners/[guild_id](#DOCS_RESOURCES_GUILD/guild-object)/[guild_banner](#DOCS_RESOURCES_GUILD/guild-object).png | PNG, JPEG, WebP |
311
- | User Banner | banners/[user_id](#DOCS_RESOURCES_USER/user-object)/[user_banner](#DOCS_RESOURCES_USER/user-object).png \* | PNG, JPEG, WebP, GIF |
312
- | Default User Avatar | embed/avatars/[user_discriminator](#DOCS_RESOURCES_USER/user-object).png \*\* \*\*\* | PNG |
313
- | User Avatar | avatars/[user_id](#DOCS_RESOURCES_USER/user-object)/[user_avatar](#DOCS_RESOURCES_USER/user-object).png \* | PNG, JPEG, WebP, GIF |
314
- | Guild Member Avatar | guilds/[guild_id](#DOCS_RESOURCES_GUILD/guild-object)/users/[user_id](#DOCS_RESOURCES_USER/user-object)/avatars/[member_avatar](#DOCS_RESOURCES_GUILD/guild-member-object).png \* | PNG, JPEG, WebP, GIF |
315
- | Application Icon | app-icons/[application_id](#DOCS_RESOURCES_APPLICATION/application-object)/[icon](#DOCS_RESOURCES_APPLICATION/application-object).png | PNG, JPEG, WebP |
316
- | Application Cover | app-icons/[application_id](#DOCS_RESOURCES_APPLICATION/application-object)/[cover_image](#DOCS_RESOURCES_APPLICATION/application-object).png | PNG, JPEG, WebP |
317
- | Application Asset | app-assets/[application_id](#DOCS_RESOURCES_APPLICATION/application-object)/[asset_id](#DOCS_TOPICS_GATEWAY/activity-object-activity-assets).png | PNG, JPEG, WebP |
318
- | Achievement Icon | app-assets/[application_id](#DOCS_RESOURCES_APPLICATION/application-object)/achievements/[achievement_id](#DOCS_GAME_SDK_ACHIEVEMENTS/data-models-user-achievement-struct)/icons/[icon_hash](#DOCS_GAME_SDK_ACHIEVEMENTS/data-models-user-achievement-struct).png | PNG, JPEG, WebP |
319
- | Sticker Pack Banner | app-assets/710982414301790216/store/[sticker_pack_banner_asset_id](#DOCS_RESOURCES_STICKER/sticker-pack-object).png | PNG, JPEG, WebP |
320
- | Team Icon | team-icons/[team_id](#DOCS_TOPICS_TEAMS/data-models-team-object)/[team_icon](#DOCS_TOPICS_TEAMS/data-models-team-object).png | PNG, JPEG, WebP |
321
- | Sticker | stickers/[sticker_id](#DOCS_RESOURCES_STICKER/sticker-object).png \*\*\* \*\*\*\* | PNG, Lottie |
322
- | Role Icon | role-icons/[role_id](#DOCS_TOPICS_PERMISSIONS/role-object)/[role_icon](#DOCS_TOPICS_PERMISSIONS/role-object).png | PNG, JPEG, WebP |
323
- | Guild Scheduled Event Cover | guild-events/[scheduled_event_id](#DOCS_RESOURCES_GUILD_SCHEDULED_EVENT/guild-scheduled-event-object)/[scheduled_event_cover_image](#DOCS_RESOURCES_GUILD_SCHEDULED_EVENT/guild-scheduled-event-object).png | PNG, JPEG, WebP |
324
-
325
- \* In the case of endpoints that support GIFs, the hash will begin with `a_` if it is available in GIF format. (example: `a_1269e74af4df7417b13759eae50c83dc`)
326
-
327
- \*\* In the case of the Default User Avatar endpoint, the value for `user_discriminator` in the path should be the user's discriminator modulo 5—Test#1337 would be `1337 % 5`, which evaluates to 2.
328
-
329
- \*\*\* In the case of the Default User Avatar and Sticker endpoints, the size of images returned is constant with the "size" querystring parameter being ignored.
330
-
331
- \*\*\*\* In the case of the Sticker endpoint, the sticker will be available as PNG if its [`format_type`](#DOCS_RESOURCES_STICKER/sticker-object) is `PNG` or `APNG`, and as [Lottie](https://airbnb.io/lottie/#/) if its `format_type` is `LOTTIE`.
332
-
333
- ## Image Data
334
-
335
- Image data is a [Data URI scheme](https://en.wikipedia.org/wiki/Data_URI_scheme) that supports JPG, GIF, and PNG formats. An example Data URI format is:
336
-
337
- ```
338
- data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA
339
- ```
340
-
341
- Ensure you use the proper content type (`image/jpeg`, `image/png`, `image/gif`) that matches the image data being provided.
342
-
343
- ## Uploading Files
344
-
345
- Some endpoints support file attachments, indicated by the `files[n]` parameter. To add a file to the request, the standard `application/json` body must be replaced by a `multipart/form-data` body. The otherwise json body can instead be provided using a special `payload_json` parameter in addition to a number of `files[n]` parameters.
346
-
347
- All `files[n]` parameters must include a valid `Content-Disposition` subpart header with a `filename` and unique `name` parameter. Each file parameter must be uniquely named in the format `files[n]` such as `files[0]`, `files[1]`, or `files[42]`. The suffixed index `n` is the *snowflake placeholder* for the `attachments` json parameter that is supplied in `payload_json` (or [Callback Data Payloads](#DOCS_INTERACTIONS_RECEIVING_AND_RESPONDING/interaction-response-object-interaction-callback-data-structure)).
348
-
349
- The file upload limit applies to the entire request, not individual files in a request. This limit depends on the **Boost Tier** of a Guild and is 8 MiB by default.
350
-
351
- Images can also be referenced in embeds using the `attachment://filename` URL. The `filename` for these URLs must be ASCII alphanumeric with underscores, dashes, or dots. An example payload is provided below.
352
-
353
- ### Editing Message Attachments
354
-
355
- All files added to a request, as described above, will be appended to the message in a `PATCH` request. The `attachments` json parameter has a special behavior for edit, as it is used for both removing attachments from the message as well as adding descriptions for new attachments added by the request.
356
-
357
- The `attachments` json parameter lists all files that should be attached to the message after the edit, including all new files added and the respective snowflake placeholders. To remove attachments, simply exclude them from this list.
358
-
359
- ###### Example Request Bodies (multipart/form-data)
360
-
361
- Note that these examples are small sections of an HTTP request to demonstrate behaviour of this endpoint - client libraries will set their own form boundaries, `boundary` is just an example. For more information, refer to the [multipart/form-data spec](https://tools.ietf.org/html/rfc7578#section-4).
362
-
363
- This example demonstrates usage of the endpoint *without* `payload_json`.
364
-
365
- ```
366
- --boundary
367
- Content-Disposition: form-data; name="content"
368
-
369
- Hello, World!
370
- --boundary
371
- Content-Disposition: form-data; name="tts"
372
-
373
- true
374
- --boundary--
375
- ```
376
-
377
- This example demonstrates usage of the endpoint *with* `payload_json` and all content fields (`content`, `embeds`, `files[n]`) set.
378
-
379
- ```
380
- --boundary
381
- Content-Disposition: form-data; name="payload_json"
382
- Content-Type: application/json
383
-
384
- {
385
- "content": "Hello, World!",
386
- "embeds": [{
387
- "title": "Hello, Embed!",
388
- "description": "This is an embedded message.",
389
- "thumbnail": {
390
- "url": "attachment://myfilename.png"
391
- },
392
- "image": {
393
- "url": "attachment://mygif.gif"
394
- }
395
- }],
396
- "message_reference": {
397
- "message_id": "233648473390448641"
398
- },
399
- "attachments": [{
400
- "id": 0,
401
- "description": "Image of a cute little cat",
402
- "filename": "file.png"
403
- }, {
404
- "id": 1,
405
- "description": "Rickroll gif",
406
- "filename": "mygif.gif"
407
- }]
408
- }
409
- --boundary
410
- Content-Disposition: form-data; name="files[0]"; filename="file.png"
411
- Content-Type: image/png
412
-
413
- [image bytes]
414
- --boundary
415
- Content-Disposition: form-data; name="files[1]"; filename="mygif.gif"
416
- Content-Type: image/gif
417
-
418
- [image bytes]
419
- --boundary--
420
- ```
421
-
422
- ###### Using Attachments within Embeds
423
-
424
- You can upload attachments when creating a message and use those attachments within your embed. To do this, you will want to upload files as part of your `multipart/form-data` body. Make sure that you're uploading files that contain a filename, as you will need a filename to reference against.
425
-
426
- > warn
427
- > Only filenames with proper image extensions are supported for the time being.
428
-
429
- In the embed object, you can then set an image to use an attachment as its url with our attachment scheme syntax: `attachment://filename.png`
430
-
431
- For example:
432
-
433
- ```json
434
- {
435
- "embeds": [{
436
- "image": {
437
- "url": "attachment://screenshot.png"
438
- }
439
- }]
440
- }
441
- ```
442
-
443
- ## Locales
444
-
445
- | Locale | Language Name |
446
- | ------ | ----------------------- |
447
- | en-US | English (United States) |
448
- | en-GB | English (Great Britain) |
449
- | bg | Bulgarian |
450
- | zh-CN | Chinese (China) |
451
- | zh-TW | Chinese (Taiwan) |
452
- | hr | Croatian |
453
- | cs | Czech |
454
- | da | Danish |
455
- | nl | Dutch |
456
- | fi | Finnish |
457
- | fr | French |
458
- | de | German |
459
- | el | Greek |
460
- | hi | Hindi |
461
- | hu | Hungarian |
462
- | it | Italian |
463
- | ja | Japanese |
464
- | ko | Korean |
465
- | lt | Lithuanian |
466
- | no | Norwegian |
467
- | pl | Polish |
468
- | pt-BR | Portuguese (Brazil) |
469
- | ro | Romanian |
470
- | ru | Russian |
471
- | es-ES | Spanish (Spain) |
472
- | sv-SE | Swedish |
473
- | th | Thai |
474
- | tr | Turkish |
475
- | uk | Ukrainian |
476
- | vi | Vietnamese |