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,306 +0,0 @@
1
- # Opcodes and Status Codes
2
-
3
- ## Gateway
4
-
5
- All gateway events in Discord are tagged with an opcode that denotes the payload type. Your connection to our gateway may also sometimes close. When it does, you will receive a close code that tells you what happened.
6
-
7
- ###### Gateway Opcodes
8
-
9
- | Code | Name | Client Action | Description |
10
- |------|-----------------------|---------------|-----------------------------------------------------------------------------------------|
11
- | 0 | Dispatch | Receive | An event was dispatched. |
12
- | 1 | Heartbeat | Send/Receive | Fired periodically by the client to keep the connection alive. |
13
- | 2 | Identify | Send | Starts a new session during the initial handshake. |
14
- | 3 | Presence Update | Send | Update the client's presence. |
15
- | 4 | Voice State Update | Send | Used to join/leave or move between voice channels. |
16
- | 6 | Resume | Send | Resume a previous session that was disconnected. |
17
- | 7 | Reconnect | Receive | You should attempt to reconnect and resume immediately. |
18
- | 8 | Request Guild Members | Send | Request information about offline guild members in a large guild. |
19
- | 9 | Invalid Session | Receive | The session has been invalidated. You should reconnect and identify/resume accordingly. |
20
- | 10 | Hello | Receive | Sent immediately after connecting, contains the `heartbeat_interval` to use. |
21
- | 11 | Heartbeat ACK | Receive | Sent in response to receiving a heartbeat to acknowledge that it has been received. |
22
-
23
- ###### Gateway Close Event Codes
24
-
25
- In order to prevent broken reconnect loops, you should consider some close codes as a signal to stop reconnnecting. This can be because your token expired, or your identification is invalid. This table explains what the application defined close codes for the gateway are, and which close codes you should not attempt to reconnect.
26
-
27
-
28
- | Code | Description | Explanation | Reconnect |
29
- |------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
30
- | 4000 | Unknown error | We're not sure what went wrong. Try reconnecting? | true |
31
- | 4001 | Unknown opcode | You sent an invalid [Gateway opcode](#DOCS_TOPICS_OPCODES_AND_STATUS_CODES/gateway-gateway-opcodes) or an invalid payload for an opcode. Don't do that! | true |
32
- | 4002 | Decode error | You sent an invalid [payload](#DOCS_TOPICS_GATEWAY/sending-payloads) to us. Don't do that! | true |
33
- | 4003 | Not authenticated | You sent us a payload prior to [identifying](#DOCS_TOPICS_GATEWAY/identify). | true |
34
- | 4004 | Authentication failed | The account token sent with your [identify payload](#DOCS_TOPICS_GATEWAY/identify) is incorrect. | false |
35
- | 4005 | Already authenticated | You sent more than one identify payload. Don't do that! | true |
36
- | 4007 | Invalid `seq` | The sequence sent when [resuming](#DOCS_TOPICS_GATEWAY/resume) the session was invalid. Reconnect and start a new session. | true |
37
- | 4008 | Rate limited | Woah nelly! You're sending payloads to us too quickly. Slow it down! You will be disconnected on receiving this. | true |
38
- | 4009 | Session timed out | Your session timed out. Reconnect and start a new one. | true |
39
- | 4010 | Invalid shard | You sent us an invalid [shard when identifying](#DOCS_TOPICS_GATEWAY/sharding). | false |
40
- | 4011 | Sharding required | The session would have handled too many guilds - you are required to [shard](#DOCS_TOPICS_GATEWAY/sharding) your connection in order to connect. | false |
41
- | 4012 | Invalid API version | You sent an invalid version for the gateway. | false |
42
- | 4013 | Invalid intent(s) | You sent an invalid intent for a [Gateway Intent](#DOCS_TOPICS_GATEWAY/gateway-intents). You may have incorrectly calculated the bitwise value. | false |
43
- | 4014 | Disallowed intent(s) | You sent a disallowed intent for a [Gateway Intent](#DOCS_TOPICS_GATEWAY/gateway-intents). You may have tried to specify an intent that you [have not enabled or are not approved for](#DOCS_TOPICS_GATEWAY/privileged-intents). | false |
44
-
45
- ## Voice
46
-
47
- Our voice gateways have their own set of opcodes and close codes.
48
-
49
- ###### Voice Opcodes
50
-
51
- | Code | Name | Sent By | Description |
52
- |------|---------------------|-------------------|----------------------------------------------------------|
53
- | 0 | Identify | client | Begin a voice websocket connection. |
54
- | 1 | Select Protocol | client | Select the voice protocol. |
55
- | 2 | Ready | server | Complete the websocket handshake. |
56
- | 3 | Heartbeat | client | Keep the websocket connection alive. |
57
- | 4 | Session Description | server | Describe the session. |
58
- | 5 | Speaking | client and server | Indicate which users are speaking. |
59
- | 6 | Heartbeat ACK | server | Sent to acknowledge a received client heartbeat. |
60
- | 7 | Resume | client | Resume a connection. |
61
- | 8 | Hello | server | Time to wait between sending heartbeats in milliseconds. |
62
- | 9 | Resumed | server | Acknowledge a successful session resume. |
63
- | 13 | Client Disconnect | server | A client has disconnected from the voice channel |
64
-
65
- ###### Voice Close Event Codes
66
-
67
- | Code | Description | Explanation |
68
- |------|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
69
- | 4001 | Unknown opcode | You sent an invalid [opcode](#DOCS_TOPICS_OPCODES_AND_STATUS_CODES/voice-voice-opcodes). |
70
- | 4002 | Failed to decode payload | You sent a invalid payload in your [identifying](#DOCS_TOPICS_GATEWAY/identify) to the Gateway. |
71
- | 4003 | Not authenticated | You sent a payload before [identifying](#DOCS_TOPICS_GATEWAY/identify) with the Gateway. |
72
- | 4004 | Authentication failed | The token you sent in your [identify](#DOCS_TOPICS_GATEWAY/identify) payload is incorrect. |
73
- | 4005 | Already authenticated | You sent more than one [identify](#DOCS_TOPICS_GATEWAY/identify) payload. Stahp. |
74
- | 4006 | Session no longer valid | Your session is no longer valid. |
75
- | 4009 | Session timeout | Your session has timed out. |
76
- | 4011 | Server not found | We can't find the server you're trying to connect to. |
77
- | 4012 | Unknown protocol | We didn't recognize the [protocol](#DOCS_TOPICS_VOICE_CONNECTIONS/establishing-a-voice-udp-connection-example-select-protocol-payload) you sent. |
78
- | 4014 | Disconnected | Channel was deleted, you were kicked, voice server changed, or the main gateway session was dropped. Should not reconnect. |
79
- | 4015 | Voice server crashed | The server crashed. Our bad! Try [resuming](#DOCS_TOPICS_VOICE_CONNECTIONS/resuming-voice-connection). |
80
- | 4016 | Unknown encryption mode | We didn't recognize your [encryption](#DOCS_TOPICS_VOICE_CONNECTIONS/encrypting-and-sending-voice). |
81
-
82
- ## HTTP
83
-
84
- Our API will return semantically valid HTTP response codes based on the success of your request. The following table can be used as a reference for response codes it will return.
85
-
86
- ###### HTTP Response Codes
87
-
88
- | Code | Meaning |
89
- |---------------------------|----------------------------------------------------------------------------------|
90
- | 200 (OK) | The request completed successfully. |
91
- | 201 (CREATED) | The entity was created successfully. |
92
- | 204 (NO CONTENT) | The request completed successfully but returned no content. |
93
- | 304 (NOT MODIFIED) | The entity was not modified (no action was taken). |
94
- | 400 (BAD REQUEST) | The request was improperly formatted, or the server couldn't understand it. |
95
- | 401 (UNAUTHORIZED) | The `Authorization` header was missing or invalid. |
96
- | 403 (FORBIDDEN) | The `Authorization` token you passed did not have permission to the resource. |
97
- | 404 (NOT FOUND) | The resource at the location specified doesn't exist. |
98
- | 405 (METHOD NOT ALLOWED) | The HTTP method used is not valid for the location specified. |
99
- | 429 (TOO MANY REQUESTS) | You are being rate limited, see [Rate Limits](#DOCS_TOPICS_RATE_LIMITS). |
100
- | 502 (GATEWAY UNAVAILABLE) | There was not a gateway available to process your request. Wait a bit and retry. |
101
- | 5xx (SERVER ERROR) | The server had an error processing your request (these are rare). |
102
-
103
- ## JSON
104
-
105
- Along with the HTTP error code, our API can also return more detailed error codes through a `code` key in the JSON error response. The response will also contain a `message` key containing a more friendly error string. Some of these errors may include additional details in the form of [Error Messages](#DOCS_REFERENCE/error-messages) provided by an `errors` object.
106
-
107
- ###### JSON Error Codes
108
-
109
- | Code | Meaning |
110
- |--------|-------------------------------------------------------------------------------------------------------------------------------|
111
- | 0 | General error (such as a malformed request body, amongst other things) |
112
- | 10001 | Unknown account |
113
- | 10002 | Unknown application |
114
- | 10003 | Unknown channel |
115
- | 10004 | Unknown guild |
116
- | 10005 | Unknown integration |
117
- | 10006 | Unknown invite |
118
- | 10007 | Unknown member |
119
- | 10008 | Unknown message |
120
- | 10009 | Unknown permission overwrite |
121
- | 10010 | Unknown provider |
122
- | 10011 | Unknown role |
123
- | 10012 | Unknown token |
124
- | 10013 | Unknown user |
125
- | 10014 | Unknown emoji |
126
- | 10015 | Unknown webhook |
127
- | 10016 | Unknown webhook service |
128
- | 10020 | Unknown session |
129
- | 10026 | Unknown ban |
130
- | 10027 | Unknown SKU |
131
- | 10028 | Unknown Store Listing |
132
- | 10029 | Unknown entitlement |
133
- | 10030 | Unknown build |
134
- | 10031 | Unknown lobby |
135
- | 10032 | Unknown branch |
136
- | 10033 | Unknown store directory layout |
137
- | 10036 | Unknown redistributable |
138
- | 10038 | Unknown gift code |
139
- | 10049 | Unknown stream |
140
- | 10050 | Unknown premium server subscribe cooldown |
141
- | 10057 | Unknown guild template |
142
- | 10059 | Unknown discoverable server category |
143
- | 10060 | Unknown sticker |
144
- | 10062 | Unknown interaction |
145
- | 10063 | Unknown application command |
146
- | 10065 | Unknown voice state |
147
- | 10066 | Unknown application command permissions |
148
- | 10067 | Unknown Stage Instance |
149
- | 10068 | Unknown Guild Member Verification Form |
150
- | 10069 | Unknown Guild Welcome Screen |
151
- | 10070 | Unknown Guild Scheduled Event |
152
- | 10071 | Unknown Guild Scheduled Event User |
153
- | 20001 | Bots cannot use this endpoint |
154
- | 20002 | Only bots can use this endpoint |
155
- | 20009 | Explicit content cannot be sent to the desired recipient(s) |
156
- | 20012 | You are not authorized to perform this action on this application |
157
- | 20016 | This action cannot be performed due to slowmode rate limit |
158
- | 20018 | Only the owner of this account can perform this action |
159
- | 20022 | This message cannot be edited due to announcement rate limits |
160
- | 20028 | The channel you are writing has hit the write rate limit |
161
- | 20029 | The write action you are performing on the server has hit the write rate limit |
162
- | 20031 | Your Stage topic, server name, server description, or channel names contain words that are not allowed |
163
- | 20035 | Guild premium subscription level too low |
164
- | 30001 | Maximum number of guilds reached (100) |
165
- | 30002 | Maximum number of friends reached (1000) |
166
- | 30003 | Maximum number of pins reached for the channel (50) |
167
- | 30004 | Maximum number of recipients reached (10) |
168
- | 30005 | Maximum number of guild roles reached (250) |
169
- | 30007 | Maximum number of webhooks reached (10) |
170
- | 30008 | Maximum number of emojis reached |
171
- | 30010 | Maximum number of reactions reached (20) |
172
- | 30013 | Maximum number of guild channels reached (500) |
173
- | 30015 | Maximum number of attachments in a message reached (10) |
174
- | 30016 | Maximum number of invites reached (1000) |
175
- | 30018 | Maximum number of animated emojis reached |
176
- | 30019 | Maximum number of server members reached |
177
- | 30030 | Maximum number of server categories has been reached (5) |
178
- | 30031 | Guild already has a template |
179
- | 30033 | Max number of thread participants has been reached (1000) |
180
- | 30035 | Maximum number of bans for non-guild members have been exceeded |
181
- | 30037 | Maximum number of bans fetches has been reached |
182
- | 30038 | Maximum number of uncompleted guild scheduled events reached (100) |
183
- | 30039 | Maximum number of stickers reached |
184
- | 30040 | Maximum number of prune requests has been reached. Try again later |
185
- | 30042 | Maximum number of guild widget settings updates has been reached. Try again later |
186
- | 30046 | Maximum number of edits to messages older than 1 hour reached. Try again later |
187
- | 40001 | Unauthorized. Provide a valid token and try again |
188
- | 40002 | You need to verify your account in order to perform this action |
189
- | 40003 | You are opening direct messages too fast |
190
- | 40004 | Send messages has been temporarily disabled |
191
- | 40005 | Request entity too large. Try sending something smaller in size |
192
- | 40006 | This feature has been temporarily disabled server-side |
193
- | 40007 | The user is banned from this guild |
194
- | 40032 | Target user is not connected to voice |
195
- | 40033 | This message has already been crossposted |
196
- | 40041 | An application command with that name already exists |
197
- | 40060 | Interaction has already been acknowledged |
198
- | 50001 | Missing access |
199
- | 50002 | Invalid account type |
200
- | 50003 | Cannot execute action on a DM channel |
201
- | 50004 | Guild widget disabled |
202
- | 50005 | Cannot edit a message authored by another user |
203
- | 50006 | Cannot send an empty message |
204
- | 50007 | Cannot send messages to this user |
205
- | 50008 | Cannot send messages in a non-text channel |
206
- | 50009 | Channel verification level is too high for you to gain access |
207
- | 50010 | OAuth2 application does not have a bot |
208
- | 50011 | OAuth2 application limit reached |
209
- | 50012 | Invalid OAuth2 state |
210
- | 50013 | You lack permissions to perform that action |
211
- | 50014 | Invalid authentication token provided |
212
- | 50015 | Note was too long |
213
- | 50016 | Provided too few or too many messages to delete. Must provide at least 2 and fewer than 100 messages to delete |
214
- | 50019 | A message can only be pinned to the channel it was sent in |
215
- | 50020 | Invite code was either invalid or taken |
216
- | 50021 | Cannot execute action on a system message |
217
- | 50024 | Cannot execute action on this channel type |
218
- | 50025 | Invalid OAuth2 access token provided |
219
- | 50026 | Missing required OAuth2 scope |
220
- | 50027 | Invalid webhook token provided |
221
- | 50028 | Invalid role |
222
- | 50033 | Invalid Recipient(s) |
223
- | 50034 | A message provided was too old to bulk delete |
224
- | 50035 | Invalid form body (returned for both `application/json` and `multipart/form-data` bodies), or invalid `Content-Type` provided |
225
- | 50036 | An invite was accepted to a guild the application's bot is not in |
226
- | 50041 | Invalid API version provided |
227
- | 50045 | File uploaded exceeds the maximum size |
228
- | 50046 | Invalid file uploaded |
229
- | 50054 | Cannot self-redeem this gift |
230
- | 50055 | Invalid Guild |
231
- | 50068 | Invalid message type |
232
- | 50070 | Payment source required to redeem gift |
233
- | 50074 | Cannot delete a channel required for Community guilds |
234
- | 50081 | Invalid sticker sent |
235
- | 50083 | Tried to perform an operation on an archived thread, such as editing a message or adding a user to the thread |
236
- | 50084 | Invalid thread notification settings |
237
- | 50085 | `before` value is earlier than the thread creation date |
238
- | 50086 | Community server channels must be text channels |
239
- | 50095 | This server is not available in your location |
240
- | 50097 | This server needs monetization enabled in order to perform this action |
241
- | 50101 | This server needs more boosts to perform this action |
242
- | 50109 | The request body contains invalid JSON. |
243
- | 60003 | Two factor is required for this operation |
244
- | 80004 | No users with DiscordTag exist |
245
- | 90001 | Reaction was blocked |
246
- | 130000 | API resource is currently overloaded. Try again a little later |
247
- | 150006 | The Stage is already open |
248
- | 160002 | Cannot reply without permission to read message history |
249
- | 160004 | A thread has already been created for this message |
250
- | 160005 | Thread is locked |
251
- | 160006 | Maximum number of active threads reached |
252
- | 160007 | Maximum number of active announcement threads reached |
253
- | 170001 | Invalid JSON for uploaded Lottie file |
254
- | 170002 | Uploaded Lotties cannot contain rasterized images such as PNG or JPEG |
255
- | 170003 | Sticker maximum framerate exceeded |
256
- | 170004 | Sticker frame count exceeds maximum of 1000 frames |
257
- | 170005 | Lottie animation maximum dimensions exceeded |
258
- | 170006 | Sticker frame rate is either too small or too large |
259
- | 170007 | Sticker animation duration exceeds maximum of 5 seconds |
260
- | 180000 | Cannot update a finished event |
261
- | 180002 | Failed to create stage needed for stage event |
262
-
263
- ###### Example JSON Error Response
264
-
265
- ```json
266
- {
267
- "message": "Invalid authentication token",
268
- "code": 50014
269
- }
270
- ```
271
-
272
- ## RPC
273
-
274
- RPC is the [local Discord server](#DOCS_TOPICS_RPC/) running on localhost. Access to the RPC server requires approval from Discord.
275
-
276
- ###### RPC Error Codes
277
-
278
- | Code | Name | Description |
279
- |------|------------------------------------|---------------------------------------------------------------------------------------|
280
- | 1000 | Unknown error | An unknown error occurred. |
281
- | 4000 | Invalid payload | You sent an invalid payload. |
282
- | 4002 | Invalid command | Invalid command name specified. |
283
- | 4003 | Invalid guild | Invalid guild ID specified. |
284
- | 4004 | Invalid event | Invalid event name specified. |
285
- | 4005 | Invalid channel | Invalid channel ID specified. |
286
- | 4006 | Invalid permissions | You lack permissions to access the given resource. |
287
- | 4007 | Invalid client ID | An invalid OAuth2 application ID was used to authorize or authenticate with. |
288
- | 4008 | Invalid origin | An invalid OAuth2 application origin was used to authorize or authenticate with. |
289
- | 4009 | Invalid token | An invalid OAuth2 token was used to authorize or authenticate with. |
290
- | 4010 | Invalid user | The specified user ID was invalid. |
291
- | 5000 | OAuth2 error | A standard OAuth2 error occurred; check the data object for the OAuth2 error details. |
292
- | 5001 | Select channel timed out | An asynchronous `SELECT_TEXT_CHANNEL`/`SELECT_VOICE_CHANNEL` command timed out. |
293
- | 5002 | `GET_GUILD` timed out | An asynchronous `GET_GUILD` command timed out. |
294
- | 5003 | Select voice force required | You tried to join a user to a voice channel but the user was already in one. |
295
- | 5004 | Capture shortcut already listening | You tried to capture more than one shortcut key at once. |
296
-
297
- ###### RPC Close Event Codes
298
-
299
- | Code | Name | Description |
300
- |------|-------------------|---------------------------------------------------------------------------|
301
- | 4000 | Invalid client ID | You connected to the RPC server with an invalid client ID. |
302
- | 4001 | Invalid origin | You connected to the RPC server with an invalid origin. |
303
- | 4002 | Rate limited | You are being rate limited. |
304
- | 4003 | Token revoked | The OAuth2 token associated with a connection was revoked, get a new one! |
305
- | 4004 | Invalid version | The RPC Server version specified in the connection string was not valid. |
306
- | 4005 | Invalid encoding | The encoding specified in the connection string was not valid. |
@@ -1,229 +0,0 @@
1
- # Permissions
2
-
3
- Permissions in Discord are a way to limit and grant certain abilities to users. A set of base permissions can be configured at the guild level for different roles. When these roles are attached to users, they grant or revoke specific privileges within the guild. Along with the guild-level permissions, Discord also supports permission overwrites that can be assigned to individual guild roles or guild members on a per-channel basis.
4
-
5
- Permissions are stored within a variable-length integer serialized into a string, and are calculated using bitwise operations. For example, the permission value `123` will be serialized as `"123"`. For long-term stability, we recommend deserializing the permissions using your languages' Big Integer libraries. The total permissions integer can be determined by ORing together each individual value, and flags can be checked using AND operations.
6
-
7
- In API v8, all permissions—including `allow` and `deny` fields in overwrites—are serialized as strings. There are also no longer `_new` permission fields; all new permissions are rolled back into the base field.
8
-
9
- In API v6, the `permissions`, `allow`, and `deny` fields in roles and overwrites are still serialized as a number; however, these numbers shall not grow beyond 31 bits. During the remaining lifetime of API v6, all new permission bits will only be introduced in `permissions_new`, `allow_new`, and `deny_new`. These `_new` fields are just for response serialization; requests with these fields should continue to use the original `permissions`, `allow`, and `deny` fields, which accept both string or number values.
10
-
11
- ```python
12
- # Permissions value that can Send Messages (0x800) and Add Reactions (0x40):
13
- permissions = 0x40 | 0x800 # 2112
14
-
15
- # Checking for flags that are set:
16
- (permissions & 0x40) == 0x40 # True
17
- (permissions & 0x800) == 0x800 # True
18
-
19
- # Kick Members (0x2) was not set:
20
- (permissions & 0x2) == 0x2 # False
21
- ```
22
-
23
- Additional logic is required when permission overwrites are involved; this is further explained below. For more information about bitwise operations and flags, see [this page](https://en.wikipedia.org/wiki/Bit_field).
24
-
25
- Below is a table of all current permissions, their integer values in hexadecimal, brief descriptions of the privileges that they grant, and the channel type they apply to, if applicable.
26
-
27
- ###### Bitwise Permission Flags
28
-
29
- | Permission | Value | Description | Channel Type |
30
- | ----------------------------- | -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
31
- | CREATE_INSTANT_INVITE | `0x0000000000000001` `(1 << 0)` | Allows creation of instant invites | T, V, S |
32
- | KICK_MEMBERS \* | `0x0000000000000002` `(1 << 1)` | Allows kicking members | |
33
- | BAN_MEMBERS \* | `0x0000000000000004` `(1 << 2)` | Allows banning members | |
34
- | ADMINISTRATOR \* | `0x0000000000000008` `(1 << 3)` | Allows all permissions and bypasses channel permission overwrites | |
35
- | MANAGE_CHANNELS \* | `0x0000000000000010` `(1 << 4)` | Allows management and editing of channels | T, V, S |
36
- | MANAGE_GUILD \* | `0x0000000000000020` `(1 << 5)` | Allows management and editing of the guild | |
37
- | ADD_REACTIONS | `0x0000000000000040` `(1 << 6)` | Allows for the addition of reactions to messages | T |
38
- | VIEW_AUDIT_LOG | `0x0000000000000080` `(1 << 7)` | Allows for viewing of audit logs | |
39
- | PRIORITY_SPEAKER | `0x0000000000000100` `(1 << 8)` | Allows for using priority speaker in a voice channel | V |
40
- | STREAM | `0x0000000000000200` `(1 << 9)` | Allows the user to go live | V |
41
- | VIEW_CHANNEL | `0x0000000000000400` `(1 << 10)` | Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels | T, V, S |
42
- | SEND_MESSAGES | `0x0000000000000800` `(1 << 11)` | Allows for sending messages in a channel (does not allow sending messages in threads) | T |
43
- | SEND_TTS_MESSAGES | `0x0000000000001000` `(1 << 12)` | Allows for sending of `/tts` messages | T |
44
- | MANAGE_MESSAGES \* | `0x0000000000002000` `(1 << 13)` | Allows for deletion of other users messages | T |
45
- | EMBED_LINKS | `0x0000000000004000` `(1 << 14)` | Links sent by users with this permission will be auto-embedded | T |
46
- | ATTACH_FILES | `0x0000000000008000` `(1 << 15)` | Allows for uploading images and files | T |
47
- | READ_MESSAGE_HISTORY | `0x0000000000010000` `(1 << 16)` | Allows for reading of message history | T |
48
- | MENTION_EVERYONE | `0x0000000000020000` `(1 << 17)` | Allows for using the `@everyone` tag to notify all users in a channel, and the `@here` tag to notify all online users in a channel | T |
49
- | USE_EXTERNAL_EMOJIS | `0x0000000000040000` `(1 << 18)` | Allows the usage of custom emojis from other servers | T |
50
- | VIEW_GUILD_INSIGHTS | `0x0000000000080000` `(1 << 19)` | Allows for viewing guild insights | |
51
- | CONNECT | `0x0000000000100000` `(1 << 20)` | Allows for joining of a voice channel | V, S |
52
- | SPEAK | `0x0000000000200000` `(1 << 21)` | Allows for speaking in a voice channel | V |
53
- | MUTE_MEMBERS | `0x0000000000400000` `(1 << 22)` | Allows for muting members in a voice channel | V, S |
54
- | DEAFEN_MEMBERS | `0x0000000000800000` `(1 << 23)` | Allows for deafening of members in a voice channel | V, S |
55
- | MOVE_MEMBERS | `0x0000000001000000` `(1 << 24)` | Allows for moving of members between voice channels | V, S |
56
- | USE_VAD | `0x0000000002000000` `(1 << 25)` | Allows for using voice-activity-detection in a voice channel | V |
57
- | CHANGE_NICKNAME | `0x0000000004000000` `(1 << 26)` | Allows for modification of own nickname | |
58
- | MANAGE_NICKNAMES | `0x0000000008000000` `(1 << 27)` | Allows for modification of other users nicknames | |
59
- | MANAGE_ROLES \* | `0x0000000010000000` `(1 << 28)` | Allows management and editing of roles | T, V, S |
60
- | MANAGE_WEBHOOKS \* | `0x0000000020000000` `(1 << 29)` | Allows management and editing of webhooks | T |
61
- | MANAGE_EMOJIS_AND_STICKERS \* | `0x0000000040000000` `(1 << 30)` | Allows management and editing of emojis and stickers | |
62
- | USE_APPLICATION_COMMANDS | `0x0000000080000000` `(1 << 31)` | Allows members to use application commands, including slash commands and context menu commands. | T |
63
- | REQUEST_TO_SPEAK | `0x0000000100000000` `(1 << 32)` | Allows for requesting to speak in stage channels. (_This permission is under active development and may be changed or removed._) | S |
64
- | MANAGE_EVENTS | `0x0000000200000000` `(1 << 33)` | Allows for creating, editing, and deleting scheduled events | V, S |
65
- | MANAGE_THREADS \* | `0x0000000400000000` `(1 << 34)` | Allows for deleting and archiving threads, and viewing all private threads | T |
66
- | CREATE_PUBLIC_THREADS | `0x0000000800000000` `(1 << 35)` | Allows for creating public and announcement threads | T |
67
- | CREATE_PRIVATE_THREADS | `0x0000001000000000` `(1 << 36)` | Allows for creating private threads | T |
68
- | USE_EXTERNAL_STICKERS | `0x0000002000000000` `(1 << 37)` | Allows the usage of custom stickers from other servers | T |
69
- | SEND_MESSAGES_IN_THREADS | `0x0000004000000000` `(1 << 38)` | Allows for sending messages in threads | T |
70
- | USE_EMBEDDED_ACTIVITIES | `0x0000008000000000` `(1 << 39)` | Allows for using Activities (applications with the `EMBEDDED` flag) in a voice channel | V |
71
- | MODERATE_MEMBERS \*\* | `0x0000010000000000` `(1 << 40)` | Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels | |
72
-
73
- **\* These permissions require the owner account to use [two-factor authentication](#DOCS_TOPICS_OAUTH2/twofactor-authentication-requirement) when used on a guild that has server-wide 2FA enabled.**
74
-
75
- **\*\* See [Permissions for Timed Out Members](#DOCS_TOPICS_PERMISSIONS/permissions-for-timed-out-members) to understand how permissions are temporarily modified for timed out users.**
76
-
77
- Note that these internal permission names may be referred to differently by the Discord client. For example, "Manage Permissions" refers to MANAGE_ROLES, "Use Voice Activity" refers to USE_VAD, and "Timeout Members" refers to MODERATE_MEMBERS.
78
-
79
- ## Permission Hierarchy
80
-
81
- How permissions apply may at first seem intuitive, but there are some hidden restrictions that prevent bots from performing certain inappropriate actions based on a bot's highest role compared to its target's highest role. A bot's or user's highest role is its role that has the greatest position value in the guild, with the default @everyone role starting at 0. Permissions follow a hierarchy with the following rules:
82
-
83
- - A bot can grant roles to other users that are of a lower position than its own highest role.
84
- - A bot can edit roles of a lower position than its highest role, but it can only grant permissions it has to those roles.
85
- - A bot can only sort roles lower than its highest role.
86
- - A bot can only kick, ban, and edit nicknames for users whose highest role is lower than the bot's highest role.
87
-
88
- Otherwise, permissions do not obey the role hierarchy. For example, a user has two roles: A and B. A denies the `VIEW_CHANNEL` permission on a #coolstuff channel. B allows the `VIEW_CHANNEL` permission on the same #coolstuff channel. The user would ultimately be able to view the #coolstuff channel, regardless of the role positions.
89
-
90
- ## Permission Overwrites
91
-
92
- Certain permissions can be applied to roles or directly to members on a channel-level by using permission overwrites. Applicable permissions are indicated by a **T** for text channels, **V** for voice channels, or **S** for stage channels in the table above.
93
-
94
- When using overwrites, there are cases where permission collisions could occur for a user; that is to say, the user may have certain overwrites with permissions that contradict each other or their guild-level role permissions. With this in mind, permissions are applied to users in the following hierarchy:
95
-
96
- 1. Base permissions given to @everyone are applied at a guild level
97
- 2. Permissions allowed to a user by their roles are applied at a guild level
98
- 3. Overwrites that deny permissions for @everyone are applied at a channel level
99
- 4. Overwrites that allow permissions for @everyone are applied at a channel level
100
- 5. Overwrites that deny permissions for specific roles are applied at a channel level
101
- 6. Overwrites that allow permissions for specific roles are applied at a channel level
102
- 7. Member-specific overwrites that deny permissions are applied at a channel level
103
- 8. Member-specific overwrites that allow permissions are applied at a channel level
104
-
105
- The following pseudocode demonstrates this process programmatically:
106
-
107
- ```python
108
- def compute_base_permissions(member, guild):
109
- if guild.is_owner(member):
110
- return ALL
111
-
112
- role_everyone = guild.get_role(guild.id) # get @everyone role
113
- permissions = role_everyone.permissions
114
-
115
- for role in member.roles:
116
- permissions |= role.permissions
117
-
118
- if permissions & ADMINISTRATOR == ADMINISTRATOR:
119
- return ALL
120
-
121
- return permissions
122
-
123
- def compute_overwrites(base_permissions, member, channel):
124
- # ADMINISTRATOR overrides any potential permission overwrites, so there is nothing to do here.
125
- if base_permissions & ADMINISTRATOR == ADMINISTRATOR:
126
- return ALL
127
-
128
- permissions = base_permissions
129
- overwrite_everyone = overwrites.get(channel.guild_id) # Find (@everyone) role overwrite and apply it.
130
- if overwrite_everyone:
131
- permissions &= ~overwrite_everyone.deny
132
- permissions |= overwrite_everyone.allow
133
-
134
- # Apply role specific overwrites.
135
- overwrites = channel.permission_overwrites
136
- allow = NONE
137
- deny = NONE
138
- for role_id in member.roles:
139
- overwrite_role = overwrites.get(role_id)
140
- if overwrite_role:
141
- allow |= overwrite_role.allow
142
- deny |= overwrite_role.deny
143
-
144
- permissions &= ~deny
145
- permissions |= allow
146
-
147
- # Apply member specific overwrite if it exist.
148
- overwrite_member = overwrites.get(member.user_id)
149
- if overwrite_member:
150
- permissions &= ~overwrite_member.deny
151
- permissions |= overwrite_member.allow
152
-
153
- return permissions
154
-
155
- def compute_permissions(member, channel):
156
- base_permissions = compute_base_permissions(member, channel.guild)
157
- return compute_overwrites(base_permissions, member, channel)
158
- ```
159
-
160
- ## Implicit Permissions
161
-
162
- Permissions in Discord are sometimes implicitly denied or allowed based on logical use. The two main cases are `VIEW_CHANNEL` and `SEND_MESSAGES` for text channels. Denying a user or a role `VIEW_CHANNEL` on a channel implicitly denies other permissions on the channel. Though permissions like `SEND_MESSAGES` are not explicitly denied for the user, they are ignored because the user cannot read messages in the channel.
163
-
164
- Denying `SEND_MESSAGES` implicitly denies `MENTION_EVERYONE`, `SEND_TTS_MESSAGES`, `ATTACH_FILES`, and `EMBED_LINKS`. Again, they are not explicitly denied when doing permissions calculations, but they are ignored because the user cannot do the base action of sending messages.
165
-
166
- For voice and stage channels, denying the `CONNECT` permission also implicitly denies other permissions such as `MANAGE_CHANNEL`.
167
-
168
- There may be other cases in which certain permissions implicitly deny or allow other permissions. In all cases, it is based on logical conclusions about how a user with certain permissions should or should not interact with Discord.
169
-
170
- ## Inherited Permissions (Threads)
171
-
172
- Threads inherit permissions from the parent channel (the channel they were created in), with one exception: The `SEND_MESSAGES` permission is not inherited; users must have `SEND_MESSAGES_IN_THREADS` to send a message in a thread, which allows for users to participate in threads in places like announcement channels.
173
-
174
- Users must have the `VIEW_CHANNEL` permission to view _any_ threads in the channel, even if they are directly mentioned or added to the thread.
175
-
176
- ## Permission Syncing
177
-
178
- Permissions with regards to categories and channels within categories are a bit tricky. Rather than inheritance, permissions are calculated by means of what we call Permission Syncing. If a child channel has the same permissions and overwrites (or lack thereof) as its parent category, the channel is considered "synced" to the category. Any further changes to a **parent category** will be reflected in its synced child channels. Any further changes to a **child channel** will cause it to become de-synced from its parent category, and its permissions will no longer change with changes to its parent category.
179
-
180
- ### Role Object
181
-
182
- Roles represent a set of permissions attached to a group of users. Roles have names, colors, and can be "pinned" to the side bar, causing their members to be listed separately. Roles can have separate permission profiles for the global context (guild) and channel context. The `@everyone` role has the same ID as the guild it belongs to.
183
-
184
- ###### Role Structure
185
-
186
- | Field | Type | Description |
187
- | -------------- | ---------------------------------------------------------------------------- | ------------------------------------------------- |
188
- | id | snowflake | role id |
189
- | name | string | role name |
190
- | color | integer | integer representation of hexadecimal color code |
191
- | hoist | boolean | if this role is pinned in the user listing |
192
- | icon? | ?string | role [icon hash](#DOCS_REFERENCE/image-formatting)|
193
- | unicode_emoji? | ?string | role unicode emoji |
194
- | position | integer | position of this role |
195
- | permissions | string | permission bit set |
196
- | managed | boolean | whether this role is managed by an integration |
197
- | mentionable | boolean | whether this role is mentionable |
198
- | tags? | [role tags](#DOCS_TOPICS_PERMISSIONS/role-object-role-tags-structure) object | the tags this role has |
199
-
200
- Roles without colors (`color == 0`) do not count towards the final computed color in the user list.
201
-
202
- ###### Role Tags Structure
203
-
204
- | Field | Type | Description |
205
- | ------------------- | --------- | --------------------------------------------------- |
206
- | bot_id? | snowflake | the id of the bot this role belongs to |
207
- | integration_id? | snowflake | the id of the integration this role belongs to |
208
- | premium_subscriber? | null | whether this is the guild's premium subscriber role |
209
-
210
- ###### Example Role
211
-
212
- ```json
213
- {
214
- "id": "41771983423143936",
215
- "name": "WE DEM BOYZZ!!!!!!",
216
- "color": 3447003,
217
- "hoist": true,
218
- "icon": "cf3ced8600b777c9486c6d8d84fb4327",
219
- "unicode_emoji": null,
220
- "position": 1,
221
- "permissions": "66321471",
222
- "managed": false,
223
- "mentionable": false
224
- }
225
- ```
226
-
227
- ## Permissions For Timed Out Members
228
-
229
- Timed out members will temporarily lose all permissions except `VIEW_CHANNEL` and `READ_MESSAGE_HISTORY`. Owners and admin users with `ADMINISTRATOR` permissions are exempt.