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,312 +0,0 @@
1
- # Storage
2
-
3
- > info
4
- > Need help with the SDK? Talk to us in the [Discord Developers Server](https://discord.gg/discord-developers)!
5
-
6
- > danger
7
- > Selling SKUs on Discord is now deprecated, and will be discontinued on March 1, 2022. [Read here for more info.](https://support-dev.discord.com/hc/en-us/articles/4414590563479)
8
-
9
- We've been told that people playing games want to save their progress as they go, allowing them to come back where they left off and continue their epic journey of power.
10
-
11
- Yeah, roguelikes. Even you.
12
-
13
- Discord's storage manager lets you save data mapped to a key for easy reading, writing, and deleting both synchronously and asynchronously. It's saved to a super special directory, the Holy Grail of file mappings, that's unique per Discord user — no need to worry about your little brother overwriting your save file.
14
-
15
- Creating this manager will also spawn an IO thread for async reads and writes, so unless you really want to be blocking, you don't need to be!
16
-
17
- ## Cloud Saves
18
-
19
- If you want to take that save data on your players' computers and save it to those **BIG COMPUTERS** in the cloud, look no further! All you need to do is head over to your manifest config file and set the following property:
20
-
21
- ```js
22
- {
23
- "storage": {
24
- "sync": true
25
- }
26
- }
27
- ```
28
-
29
- Yup, that's it! Don't know what this file is? Go read [Branches and Builds](#DOCS_DISPATCH_BRANCHES_AND_BUILDS/).
30
-
31
- ## Data Models
32
-
33
- ###### FileStat Struct
34
-
35
- | name | type | description |
36
- | ------------ | ------ | -------------------------------------------- |
37
- | Filename | string | the name of the file |
38
- | Size | UInt64 | the size of the file |
39
- | LastModified | UInt64 | timestamp of when the file was last modified |
40
-
41
- ## GetPath
42
-
43
- > info
44
- > Value from environment variable `DISCORD_STORAGE_PATH`
45
-
46
- Returns the filepath to which Discord saves files if you were to use the SDK's storage manager. Discord has branch-specific, user-specific saves, so you and your little brother will never overwrite each others' save files. If your game already has save file writing logic, you can use this method to get that user-specific path and help users protect their save files.
47
-
48
- Returns a `string`.
49
-
50
- ###### Parameters
51
-
52
- None
53
-
54
- ###### Example
55
-
56
- ```cs
57
- var savePath = storageManager.GetPath();
58
- Console.WriteLine("You should write your save files to {0}", savePath);
59
- ```
60
-
61
- ## Read
62
-
63
- Reads data synchronously from the game's allocated save file into a buffer. The file is mapped by key value pairs, and this function will read data that exists for the given key name.
64
-
65
- Returns a `UInt32`.
66
-
67
- ###### Parameters
68
-
69
- | name | type | description |
70
- | ---- | ------ | ---------------------------------- |
71
- | name | string | the key name to read from the file |
72
- | data | byte[] | the buffer to read into |
73
-
74
- ## ReadAsync
75
-
76
- Reads data asynchronously from the game's allocated save file into a buffer.
77
-
78
- Returns a `Discord.Result` and a `byte[]` containing the data via callback.
79
-
80
- ###### Parameters
81
-
82
- | name | type | description |
83
- | ---- | ------ | ---------------------------------- |
84
- | name | string | the key name to read from the file |
85
-
86
- ###### Example
87
-
88
- ```cs
89
- storeManager.ReadAsync("high_score", (result, data) =>
90
- {
91
- if (result == Discord.Result.OK) {
92
- LoadHighScore(data);
93
- }
94
- });
95
- ```
96
-
97
- ## ReadAsyncPartial
98
-
99
- Reads data asynchronously from the game's allocated save file into a buffer, starting at a given offset and up to a given length.
100
-
101
- Returns a `Discord.Result` and `byte[]` containing the data via callback.
102
-
103
- ###### Parameters
104
-
105
- | name | type | description |
106
- | ------ | ------ | ------------------------------------ |
107
- | name | string | the key name to read from the file |
108
- | offset | UInt64 | the offset at which to start reading |
109
- | length | UInt64 | the length to read |
110
-
111
- ###### Example
112
-
113
- ```cs
114
- storeManager.ReadAsyncPartial("high_score", 10, 8, (result, data) =>
115
- {
116
- if (result == Discord.Result.OK) {
117
- LoadHighScore(data);
118
- }
119
- });
120
- ```
121
-
122
- ## Write
123
-
124
- Writes data synchronously to disk, under the given key name.
125
-
126
- Returns `void`.
127
-
128
- ###### Parameters
129
-
130
- | name | type | description |
131
- | ---- | ------ | --------------------------- |
132
- | name | string | the key name to write under |
133
- | data | byte[] | the data to write |
134
-
135
- ###### Example
136
-
137
- ```cs
138
- storageManager.Write("high_score", Encoding.UTF8.GetBytes("9999"));
139
- ```
140
-
141
- ## WriteAsync
142
-
143
- Writes data asynchronously to disk under the given keyname.
144
-
145
- Returns a `Discord.Result` via callback.
146
-
147
- ###### Parameters
148
-
149
- | name | type | description |
150
- | ---- | ------ | --------------------------- |
151
- | name | string | the key name to write under |
152
- | data | byte[] | the data to write |
153
-
154
- ###### Example
155
-
156
- ```cs
157
- storageManager.WriteAsync("high_score", Encoding.UTF8.GetBytes("9999"), (result) =>
158
- {
159
- if (result == Discord.Result.OK)
160
- {
161
- Console.WriteLine("Wrote data");
162
- }
163
- });
164
- ```
165
-
166
- ## Delete
167
-
168
- Deletes written data for the given key name.
169
-
170
- Returns `void`.
171
-
172
- ###### Parameters
173
-
174
- | name | type | description |
175
- | ---- | ------ | ---------------------- |
176
- | name | string | the key name to delete |
177
-
178
- ###### Example
179
-
180
- ```cs
181
- storageManager.Delete("high_score");
182
- // Because you cheated. Jerk.
183
- ```
184
-
185
- ## Exists
186
-
187
- Checks if data exists for a given key name.
188
-
189
- Returns `bool`.
190
-
191
- ###### Parameters
192
-
193
- | name | type | description |
194
- | ---- | ------ | --------------------- |
195
- | name | string | the key name to check |
196
-
197
- ###### Example
198
-
199
- ```cs
200
- var highScore = storageManager.Exists("high_score");
201
- if (!highScore)
202
- {
203
- Console.WriteLine("Couldn't find any highscore for you. Did you cheat? Jerk.");
204
- }
205
- ```
206
-
207
- ## Stat
208
-
209
- Returns file info for the given key name.
210
-
211
- Returns a `FileStat`.
212
-
213
- ###### Parameters
214
-
215
- | name | type | description |
216
- | ---- | ------ | ------------------------------ |
217
- | name | string | the key name get file data for |
218
-
219
- ###### Example
220
-
221
- ```cs
222
- var file = storageManager.Stat("high_score");
223
- Console.WriteLine("File {0} is {1} in size and was last edited at {2}", file.Name, file.Size, file.LastModified);
224
- ```
225
-
226
- ## Count
227
-
228
- Returns the count of files, for iteration.
229
-
230
- Returns an `Int32`.
231
-
232
- ###### Parameters
233
-
234
- None
235
-
236
- ###### Example
237
-
238
- ```cs
239
- var numFiles = storageManager.Count();
240
- for (int i = 0; i < numFiles; i++)
241
- {
242
- Console.WriteLine("We're at file {0}", i);
243
- }
244
- ```
245
-
246
- ## StatAt
247
-
248
- Returns file info for the given index when iterating over files.
249
-
250
- Returns a `FileStat`.
251
-
252
- ###### Parameters
253
-
254
- | name | type | description |
255
- | ----- | ----- | ------------------------------ |
256
- | index | Int32 | the index to get file data for |
257
-
258
- ###### Example
259
-
260
- ```cs
261
- var numFiles = storageManager.Count();
262
- for (int i = 0; i < numFiles; i++)
263
- {
264
- var file = storageManager.StatAt(i);
265
- Console.WriteLine("File is {0}", file.Name);
266
- }
267
- ```
268
-
269
- ## Example: Saving, Reading, Deleting, and Checking Data
270
-
271
- ```cs
272
- var discord = new Discord.Discord(clientId, Discord.CreateFlags.Default);
273
- var storageManager = discord.GetStorageManager();
274
-
275
- // Create some nonsense data
276
- var contents = new byte[20000];
277
- var random = new Random();
278
- random.NextBytes(contents);
279
-
280
- // Write the data asynchronously
281
- storageManager.WriteAsync("foo", contents, res =>
282
- {
283
- // Get our list of files and iterate over it
284
- for (int i = 0; i < storageManager.Count(); i++)
285
- {
286
- var file = storageManager.StatAt(i);
287
- Console.WriteLine("file: {0} size: {1} last_modified: {2}", file.Filename, file.Size, file.LastModified);
288
- }
289
-
290
- // Let's read just a small chunk of data from the "foo" key
291
- storageManager.ReadAsyncPartial("foo", 400, 50, (result, data) =>
292
- {
293
- Console.WriteLine("partial contents of foo match {0}", Enumerable.SequenceEqual(data, new ArraySegment<byte>(contents, 400, 50)));
294
- });
295
-
296
- // Now let's read all of "foo"
297
- storageManager.ReadAsync("foo", (result, data) =>
298
- {
299
- Console.WriteLine("length of contents {0} data {1}", contents.Length, data.Length);
300
- Console.WriteLine("contents of foo match {0}", Enumerable.SequenceEqual(data, contents));
301
-
302
- // We just read it, but let's make sure "foo" exists
303
- Console.WriteLine("foo exists? {0}", storageManager.Exists("foo"));
304
-
305
- // Now delete it
306
- storageManager.Delete("foo");
307
-
308
- // Make sure it was deleted
309
- Console.WriteLine("post-delete foo exists? {0}", storageManager.Exists("foo"));
310
- });
311
- });
312
- ```