dfx 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/DiscordREST/types.js +6 -0
  2. package/DiscordREST/types.js.map +1 -0
  3. package/DiscordWS/index.js +2 -0
  4. package/DiscordWS/index.js.map +1 -0
  5. package/README.md +3 -0
  6. package/WS/index.js +71 -0
  7. package/WS/index.js.map +1 -0
  8. package/discord-api-docs/index.js +1 -0
  9. package/mod.js.map +1 -0
  10. package/package.json +6 -1
  11. package/types.js +1563 -0
  12. package/types.js.map +1 -0
  13. package/websocket.js +11 -0
  14. package/websocket.js.map +1 -0
  15. package/.gitmodules +0 -3
  16. package/.prettierrc.json +0 -4
  17. package/discord-api-docs/.eslintrc.json +0 -10
  18. package/discord-api-docs/.gitattributes +0 -11
  19. package/discord-api-docs/.github/ISSUE_TEMPLATE/api-bug-report.yml +0 -49
  20. package/discord-api-docs/.github/ISSUE_TEMPLATE/config.yml +0 -20
  21. package/discord-api-docs/.github/ISSUE_TEMPLATE/developer-site-bug-report.yml +0 -49
  22. package/discord-api-docs/.github/ISSUE_TEMPLATE/message-components-bug-report.yml +0 -49
  23. package/discord-api-docs/.github/ISSUE_TEMPLATE/slash-command-bug-report.yml +0 -49
  24. package/discord-api-docs/.github/workflows/test.yaml +0 -45
  25. package/discord-api-docs/.prettierignore +0 -1
  26. package/discord-api-docs/.prettierrc.json +0 -15
  27. package/discord-api-docs/CODE_OF_CONDUCT.md +0 -75
  28. package/discord-api-docs/CONTRIBUTING.md +0 -16
  29. package/discord-api-docs/README.md +0 -35
  30. package/discord-api-docs/docs/Change_Log.md +0 -474
  31. package/discord-api-docs/docs/Intro.md +0 -48
  32. package/discord-api-docs/docs/Legal.md +0 -154
  33. package/discord-api-docs/docs/Policy.md +0 -81
  34. package/discord-api-docs/docs/Reference.md +0 -476
  35. package/discord-api-docs/docs/Store_Distribution_Agreement.md +0 -179
  36. package/discord-api-docs/docs/dispatch/Branches_and_Builds.md +0 -654
  37. package/discord-api-docs/docs/dispatch/Dispatch_and_You.md +0 -17
  38. package/discord-api-docs/docs/dispatch/Error_Codes.md +0 -26
  39. package/discord-api-docs/docs/dispatch/Field_Values.md +0 -48
  40. package/discord-api-docs/docs/dispatch/List_of_Commands.md +0 -315
  41. package/discord-api-docs/docs/game_and_server_management/Alpha_and_Beta_Testing.md +0 -52
  42. package/discord-api-docs/docs/game_and_server_management/How_to_Get_Your_Game_on_Discord.md +0 -110
  43. package/discord-api-docs/docs/game_and_server_management/Special_Channels.md +0 -38
  44. package/discord-api-docs/docs/game_sdk/Achievements.md +0 -405
  45. package/discord-api-docs/docs/game_sdk/Activities.md +0 -561
  46. package/discord-api-docs/docs/game_sdk/Applications.md +0 -237
  47. package/discord-api-docs/docs/game_sdk/Discord.md +0 -443
  48. package/discord-api-docs/docs/game_sdk/Discord_Voice.md +0 -289
  49. package/discord-api-docs/docs/game_sdk/Images.md +0 -196
  50. package/discord-api-docs/docs/game_sdk/Lobbies.md +0 -1639
  51. package/discord-api-docs/docs/game_sdk/Networking.md +0 -377
  52. package/discord-api-docs/docs/game_sdk/Overlay.md +0 -195
  53. package/discord-api-docs/docs/game_sdk/Relationships.md +0 -234
  54. package/discord-api-docs/docs/game_sdk/SDK_Starter_Guide.md +0 -310
  55. package/discord-api-docs/docs/game_sdk/Storage.md +0 -312
  56. package/discord-api-docs/docs/game_sdk/Store.md +0 -555
  57. package/discord-api-docs/docs/game_sdk/Users.md +0 -178
  58. package/discord-api-docs/docs/interactions/Application_Commands.md +0 -1069
  59. package/discord-api-docs/docs/interactions/Message_Components.md +0 -454
  60. package/discord-api-docs/docs/interactions/Receiving_and_Responding.md +0 -372
  61. package/discord-api-docs/docs/interactions/Slash_Commands.md +0 -3
  62. package/discord-api-docs/docs/resources/Application.md +0 -82
  63. package/discord-api-docs/docs/resources/Audit_Log.md +0 -223
  64. package/discord-api-docs/docs/resources/Channel.md +0 -1267
  65. package/discord-api-docs/docs/resources/Emoji.md +0 -122
  66. package/discord-api-docs/docs/resources/Guild.md +0 -1157
  67. package/discord-api-docs/docs/resources/Guild_Scheduled_Event.md +0 -273
  68. package/discord-api-docs/docs/resources/Guild_Template.md +0 -148
  69. package/discord-api-docs/docs/resources/Invite.md +0 -150
  70. package/discord-api-docs/docs/resources/Stage_Instance.md +0 -106
  71. package/discord-api-docs/docs/resources/Sticker.md +0 -164
  72. package/discord-api-docs/docs/resources/User.md +0 -205
  73. package/discord-api-docs/docs/resources/Voice.md +0 -55
  74. package/discord-api-docs/docs/resources/Webhook.md +0 -281
  75. package/discord-api-docs/docs/rich_presence/Best_Practices.md +0 -88
  76. package/discord-api-docs/docs/rich_presence/FAQ.md +0 -45
  77. package/discord-api-docs/docs/rich_presence/How_To.md +0 -302
  78. package/discord-api-docs/docs/rich_presence/Launch_Checklist.md +0 -46
  79. package/discord-api-docs/docs/topics/Certified_Devices.md +0 -200
  80. package/discord-api-docs/docs/topics/Community_Resources.md +0 -98
  81. package/discord-api-docs/docs/topics/Gateway.md +0 -1600
  82. package/discord-api-docs/docs/topics/OAuth2.md +0 -427
  83. package/discord-api-docs/docs/topics/Opcodes_and_Status_Codes.md +0 -306
  84. package/discord-api-docs/docs/topics/Permissions.md +0 -229
  85. package/discord-api-docs/docs/topics/RPC.md +0 -1597
  86. package/discord-api-docs/docs/topics/Rate_Limits.md +0 -126
  87. package/discord-api-docs/docs/topics/Teams.md +0 -80
  88. package/discord-api-docs/docs/topics/Threads.md +0 -163
  89. package/discord-api-docs/docs/topics/Voice_Connections.md +0 -282
  90. package/discord-api-docs/images/API_center.gif +0 -0
  91. package/discord-api-docs/images/ask-to-join.gif +0 -0
  92. package/discord-api-docs/images/available-published.png +0 -0
  93. package/discord-api-docs/images/button-styles.png +0 -0
  94. package/discord-api-docs/images/certified-device.png +0 -0
  95. package/discord-api-docs/images/command-with-groups-subcommands-parameters.png +0 -0
  96. package/discord-api-docs/images/command-with-groups-subcommands.png +0 -0
  97. package/discord-api-docs/images/command.png +0 -0
  98. package/discord-api-docs/images/cpp-files-sdk.png +0 -0
  99. package/discord-api-docs/images/create-store-channel.png +0 -0
  100. package/discord-api-docs/images/deferred-example.png +0 -0
  101. package/discord-api-docs/images/desktop-select.png +0 -0
  102. package/discord-api-docs/images/game-overlay-sdk-invite.gif +0 -0
  103. package/discord-api-docs/images/game-overlay-sdk-voice-settings.png +0 -0
  104. package/discord-api-docs/images/game-overlay-sdk-voice-widget.png +0 -0
  105. package/discord-api-docs/images/gift-code-creation.png +0 -0
  106. package/discord-api-docs/images/lib-linked-sdk.png +0 -0
  107. package/discord-api-docs/images/message-command.png +0 -0
  108. package/discord-api-docs/images/mobile-select.png +0 -0
  109. package/discord-api-docs/images/previous-new-server-background.png +0 -0
  110. package/discord-api-docs/images/rp-actionable.png +0 -0
  111. package/discord-api-docs/images/rp-all-fields.png +0 -0
  112. package/discord-api-docs/images/rp-bad-art.png +0 -0
  113. package/discord-api-docs/images/rp-good-art.png +0 -0
  114. package/discord-api-docs/images/rp-legend.png +0 -0
  115. package/discord-api-docs/images/rp-long-strings.png +0 -0
  116. package/discord-api-docs/images/rp-non-actionable.png +0 -0
  117. package/discord-api-docs/images/rp-not-all-fields.png +0 -0
  118. package/discord-api-docs/images/rp-profile-example-1.png +0 -0
  119. package/discord-api-docs/images/rp-profile-example-2.png +0 -0
  120. package/discord-api-docs/images/rp-short-strings.png +0 -0
  121. package/discord-api-docs/images/server-banner-example.png +0 -0
  122. package/discord-api-docs/images/server-banner-margin-top.png +0 -0
  123. package/discord-api-docs/images/sku-management.png +0 -0
  124. package/discord-api-docs/images/snowflake.png +0 -0
  125. package/discord-api-docs/images/snowflake_original_size.png +0 -0
  126. package/discord-api-docs/images/spectate.gif +0 -0
  127. package/discord-api-docs/images/team-2fa.png +0 -0
  128. package/discord-api-docs/images/team-make-app.png +0 -0
  129. package/discord-api-docs/images/team-page.png +0 -0
  130. package/discord-api-docs/images/transfer-app-to-team.png +0 -0
  131. package/discord-api-docs/images/user-command.png +0 -0
  132. package/discord-api-docs/package-lock.json +0 -3186
  133. package/discord-api-docs/package.json +0 -38
  134. package/discord-api-docs/tsconfig.eslint.json +0 -4
  135. package/discord-api-docs/tsconfig.json +0 -19
  136. package/tsconfig.json +0 -24
@@ -1,561 +0,0 @@
1
- # Activities
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
- Looking to integrate Rich Presence into your game? No need to manage multiple SDKs—this one does all that awesome stuff, too!. Delight your players with the ability to post game invites in chat and party up directly from Discord. Surface interesting live game data in their profile and on the Games Tab for their friends, encouraging them to group up and play together.
10
-
11
- For more detailed information and documentation around the Rich Presence feature set and integration tips, check out our [Rich Presence Documentation](https://discord.com/developers/docs/rich-presence/how-to).
12
-
13
- ## Data Models
14
-
15
- ###### User Struct
16
-
17
- | name | type | description |
18
- | ------------- | ------ | ----------------------------- |
19
- | Id | Int64 | the user's id |
20
- | Username | string | their name |
21
- | Discriminator | string | the user's unique discrim |
22
- | Avatar | string | the hash of the user's avatar |
23
- | Bot | bool | if the user is a bot user |
24
-
25
- ###### Activity Struct
26
-
27
- | name | type | description |
28
- | ------------- | ------------------ | --------------------------------------------------------------- |
29
- | ApplicationId | Int64 | your application id - this is a read-only field |
30
- | Name | string | name of the application - this is a read-only field |
31
- | State | string | the player's current party status |
32
- | Details | string | what the player is currently doing |
33
- | Timestamps | ActivityTimestamps | helps create elapsed/remaining timestamps on a player's profile |
34
- | Assets | ActivityAssets | assets to display on the player's profile |
35
- | Party | ActivityParty | information about the player's party |
36
- | Secrets | ActivitySecrets | secret passwords for joining and spectating the player's game |
37
- | Instance | bool | whether this activity is an instanced context, like a match |
38
-
39
- ###### ActivityTimestamps Struct
40
-
41
- | name | type | description |
42
- | ----- | ----- | ------------------------------------------------------ |
43
- | Start | Int64 | unix timestamp - send this to have an "elapsed" timer |
44
- | End | Int64 | unix timestamp - send this to have a "remaining" timer |
45
-
46
- ###### ActivityAssets Struct
47
-
48
- | name | type | description |
49
- | ---------- | ------ | ------------------------------------------------------------------------------------- |
50
- | LargeImage | string | see [Activity Asset Image](#DOCS_TOPICS_GATEWAY/activity-object-activity-asset-image) |
51
- | LargeText | string | hover text for the large image |
52
- | SmallImage | string | see [Activity Asset Image](#DOCS_TOPICS_GATEWAY/activity-object-activity-asset-image) |
53
- | SmallText | string | hover text for the small image |
54
-
55
- ###### ActivityParty Struct
56
-
57
- | name | type | description |
58
- | ---- | --------- | ---------------------------------- |
59
- | Id | string | a unique identifier for this party |
60
- | Size | PartySize | info about the size of the party |
61
-
62
- ###### PartySize Struct
63
-
64
- | name | type | description |
65
- | ----------- | ----- | ---------------------------------- |
66
- | CurrentSize | Int32 | the current size of the party |
67
- | MaxSize | Int32 | the max possible size of the party |
68
-
69
- ###### ActivitySecrets Struct
70
-
71
- | name | type | description |
72
- | -------- | ------ | -------------------------------------------- |
73
- | Match | string | unique hash for the given match context |
74
- | Join | string | unique hash for chat invites and Ask to Join |
75
- | Spectate | string | unique hash for Spectate button |
76
-
77
- ###### ActivityType Enum
78
-
79
- | name | Value |
80
- | --------- | ----- |
81
- | Playing | 0 |
82
- | Streaming | 1 |
83
- | Listening | 2 |
84
- | Watching | 3 |
85
- | Custom | 4 |
86
- | Competing | 5 |
87
-
88
- For more details about the activity types, [see Gateway documentation](#DOCS_TOPICS_GATEWAY/activity-object-activity-types).
89
-
90
- `ActivityType` is strictly for the purpose of handling events that you receive from Discord; though the SDK/our API will not reject a payload with an `ActivityType` sent, it will be discarded and will not change anything in the client.
91
-
92
- ###### ActivityJoinRequestReply Enum
93
-
94
- | name | value |
95
- | ------ | ----- |
96
- | No | 0 |
97
- | Yes | 1 |
98
- | Ignore | 2 |
99
-
100
- ###### ActivityActionType Enum
101
-
102
- | name | value |
103
- | -------- | ----- |
104
- | Join | 1 |
105
- | Spectate | 2 |
106
-
107
- ## Activity Action Field Requirements
108
-
109
- If you want to hook up joining and spectating for your games, there are certain fields in the activity payload that need to be sent. Refer to the following handy table for what needs to be set for certain actions.
110
-
111
- ###### Requirements
112
-
113
- | Field | Custom Artwork | Spectate | Join | Ask to Join |
114
- | ------------------------------ | :------------: | :------: | :--: | :---------: |
115
- | State | | | | |
116
- | Details | | | | |
117
- | ActivityTimestamps.Start | | | | |
118
- | ActivityTimestamps.End | | | | |
119
- | ActivityAssets.LargeImage | x | | | |
120
- | ActivityAssets.SmallImage | x | | | |
121
- | ActivityAssets.LargeText | x | | | |
122
- | ActivityAssets.SmallText | x | | | |
123
- | ActivityParty.Id | | | x | x |
124
- | ActivityParty.Size.CurrentSize | | | x | x |
125
- | ActivityParty.Size.MaxSize | | | x | x |
126
- | ActivitySecrets.Join | | | x | x |
127
- | ActivitySecrets.Spectate | | x | | |
128
-
129
- ## RegisterCommand
130
-
131
- Registers a command by which Discord can launch your game. This might be a custom protocol, like `my-awesome-game://`, or a path to an executable. It also supports any launch parameters that may be needed, like `game.exe --full-screen --no-hax`.
132
-
133
- On macOS, due to the way Discord registers executables, your game needs to be bundled for this command to work. That means it should be a `.app`.
134
-
135
- Returns `void`.
136
-
137
- ###### Parameters
138
-
139
- | name | type | description |
140
- | ------- | ------ | ----------------------- |
141
- | command | string | the command to register |
142
-
143
- ###### Example
144
-
145
- ```cs
146
- activityManager.RegisterCommand("my-awesome-game://run --full-screen");
147
- ```
148
-
149
- ## RegisterSteam
150
-
151
- Used if you are distributing this SDK on Steam. Registers your game's Steam app id for the protocol `steam://run-game-id/<id>`.
152
-
153
- Returns `void`.
154
-
155
- ###### Parameters
156
-
157
- | name | type | description |
158
- | ------- | ------ | ------------------------ |
159
- | steamId | UInt32 | your game's Steam app id |
160
-
161
- ###### Example
162
-
163
- ```cs
164
- activityManager.RegisterSteam(1938123);
165
- ```
166
-
167
- ## UpdateActivity
168
-
169
- Sets a user's presence in Discord to a new activity. This has a rate limit of 5 updates per 20 seconds.
170
-
171
- > info
172
- > It is possible for users to hide their presence on Discord (User Settings -> Game Activity). Presence set through this SDK may not be visible when this setting is toggled off.
173
-
174
- Returns a `Discord.Result` via callback.
175
-
176
- ###### Parameters
177
-
178
- | name | type | description |
179
- | -------- | -------- | ----------------------------- |
180
- | activity | Activity | the new activity for the user |
181
-
182
- ###### Example
183
-
184
- ```cs
185
- var activity = new Discord.Activity
186
- {
187
- State = "In Play Mode",
188
- Details = "Playing the Trumpet!",
189
- Timestamps =
190
- {
191
- Start = 5,
192
- },
193
- Assets =
194
- {
195
- LargeImage = "foo largeImageKey", // Larger Image Asset Value
196
- LargeText = "foo largeImageText", // Large Image Tooltip
197
- SmallImage = "foo smallImageKey", // Small Image Asset Value
198
- SmallText = "foo smallImageText", // Small Image Tooltip
199
- },
200
- Party =
201
- {
202
- Id = "foo partyID",
203
- Size = {
204
- CurrentSize = 1,
205
- MaxSize = 4,
206
- },
207
- },
208
- Secrets =
209
- {
210
- Match = "foo matchSecret",
211
- Join = "foo joinSecret",
212
- Spectate = "foo spectateSecret",
213
- },
214
- Instance = true,
215
- };
216
-
217
- activityManager.UpdateActivity(activity, (result) =>
218
- {
219
- if (result == Discord.Result.Ok)
220
- {
221
- Console.WriteLine("Success!");
222
- }
223
- else
224
- {
225
- Console.WriteLine("Failed");
226
- }
227
- });
228
- ```
229
-
230
- ## ClearActivity
231
-
232
- Clear's a user's presence in Discord to make it show nothing.
233
-
234
- Results a `Discord.Result` via callback.
235
-
236
- ###### Parameters
237
-
238
- None
239
-
240
- ###### Example
241
-
242
- ```cs
243
- activityManager.ClearActivity((result) =>
244
- {
245
- if (result == Discord.Result.Ok)
246
- {
247
- Console.WriteLine("Success!");
248
- }
249
- else
250
- {
251
- Console.WriteLine("Failed");
252
- }
253
- });
254
- ```
255
-
256
- ## SendRequestReply
257
-
258
- Sends a reply to an Ask to Join request.
259
-
260
- Returns a `Discord.Result` via callback.
261
-
262
- ###### Parameters
263
-
264
- | name | type | description |
265
- | ------ | ------------------------ | ------------------------------------------- |
266
- | userId | Int64 | the user id of the person who asked to join |
267
- | reply | ActivityJoinRequestReply | No, Yes, or Ignore |
268
-
269
- ###### Example
270
-
271
- ```cs
272
- activityManager.OnActivityJoinRequest += user =>
273
- {
274
- Console.WriteLine("Join request from: {0}", user.Id);
275
- activityManager.SendRequestReply(user.Id, Discord.ActivityJoinRequestReply.Yes, (res) =>
276
- {
277
- if (res == Discord.Result.Ok)
278
- {
279
- Console.WriteLine("Responded successfully");
280
- }
281
- });
282
- }
283
- ```
284
-
285
- ## SendInvite
286
-
287
- Sends a game invite to a given user. If you do not have a valid activity with all the required fields, this call will error. See [Activity Action Field Requirements](#DOCS_GAME_SDK_ACTIVITIES/activity-action-field-requirements) for the fields required to have join and spectate invites function properly.
288
-
289
- Returns a `Discord.Result` via callback.
290
-
291
- ###### Parameters
292
-
293
- | name | type | description |
294
- | ------- | ------------------ | ----------------------------------------------------- |
295
- | userId | Int64 | the id of the user to invite |
296
- | type | ActivityActionType | marks the invite as an invitation to join or spectate |
297
- | content | string | a message to send along with the invite |
298
-
299
- ###### Example
300
-
301
- ```cs
302
- var userId = 53908232506183680;
303
- activityManager.SendInvite(userId, Discord.ActivityActionType.Join, "Come play!", (result) =>
304
- {
305
- if (result == Discord.Result.Ok)
306
- {
307
- Console.WriteLine("Success!");
308
- }
309
- else
310
- {
311
- Console.WriteLine("Failed");
312
- }
313
- });
314
- ```
315
-
316
- ## AcceptInvite
317
-
318
- Accepts a game invitation from a given userId.
319
-
320
- Returns a `Discord.Result` via callback.
321
-
322
- ###### Parameters
323
-
324
- | name | type | description |
325
- | ------ | ----- | ---------------------------------- |
326
- | userId | Int64 | the id of the user who invited you |
327
-
328
- ###### Example
329
-
330
- ```cs
331
- activityManager.AcceptInvite(290926444748734466, (result) =>
332
- {
333
- if (result == Discord.Result.Ok)
334
- {
335
- Console.WriteLine("Success!");
336
- }
337
- else
338
- {
339
- Console.WriteLine("Failed");
340
- }
341
- });
342
- ```
343
-
344
- ## OnActivityJoin
345
-
346
- Fires when a user accepts a game chat invite or receives confirmation from Asking to Join.
347
-
348
- ###### Parameters
349
-
350
- | name | type | description |
351
- | ---------- | ------ | ---------------------------------- |
352
- | joinSecret | string | the secret to join the user's game |
353
-
354
- ###### Example
355
-
356
- ```cs
357
- // Received when someone accepts a request to join or invite.
358
- // Use secrets to receive back the information needed to add the user to the group/party/match
359
- activityManager.OnActivityJoin += secret => {
360
- Console.WriteLine("OnJoin {0}", secret);
361
- lobbyManager.ConnectLobbyWithActivitySecret(secret, (Discord.Result result, ref Discord.Lobby lobby) =>
362
- {
363
- Console.WriteLine("Connected to lobby: {0}", lobby.Id);
364
- // Connect to voice chat, used in this case to actually know in overlay if your successful in connecting.
365
- lobbyManager.ConnectVoice(lobby.Id, (Discord.Result voiceResult) => {
366
-
367
- if (voiceResult == Discord.Result.Ok)
368
- {
369
- Console.WriteLine("New User Connected to Voice! Say Hello! Result: {0}", voiceResult);
370
- }
371
- else
372
- {
373
- Console.WriteLine("Failed with Result: {0}", voiceResult);
374
- };
375
- });
376
- //Connect to given lobby with lobby Id
377
- lobbyManager.ConnectNetwork(lobby.Id);
378
- lobbyManager.OpenNetworkChannel(lobby.Id, 0, true);
379
- foreach (var user in lobbyManager.GetMemberUsers(lobby.Id))
380
- {
381
- //Send a hello message to everyone in the lobby
382
- lobbyManager.SendNetworkMessage(lobby.Id, user.Id, 0,
383
- Encoding.UTF8.GetBytes(String.Format("Hello, {0}!", user.Username)));
384
- }
385
- //Sends this off to a Activity callback named here as 'UpdateActivity' passing in the discord instance details and lobby details
386
- UpdateActivity(discord, lobby);
387
- });
388
- };
389
-
390
- void UpdateActivity(Discord.Discord discord, Discord.Lobby lobby)
391
- {
392
- //Creates a Static String for Spectate Secret.
393
- string discordSpectateSecret = "wdn3kvj320r8vk3";
394
- spectateActivitySecret = discordSpectateSecret;
395
- var activity = new Discord.Activity
396
- {
397
- State = "Playing Co-Op",
398
- Details = "In a Multiplayer Match!",
399
- Timestamps =
400
- {
401
- Start = startTimeStamp,
402
- },
403
- Assets =
404
- {
405
- LargeImage = "matchimage1",
406
- LargeText = "Inside the Arena!",
407
- },
408
- Party = {
409
- Id = lobby.Id.ToString(),
410
- Size = {
411
- CurrentSize = lobbyManager.MemberCount(lobby.Id),
412
- MaxSize = (int)lobby.Capacity,
413
- },
414
- },
415
- Secrets = {
416
- Spectate = spectateActivitySecret,
417
- Join = joinActivitySecret,
418
- },
419
- Instance = true,
420
- };
421
-
422
- activityManager.UpdateActivity(activity, result =>
423
- {
424
- Debug.LogFormat("Updated to Multiplayer Activity: {0}", result);
425
-
426
- // Send an invite to another user for this activity.
427
- // Receiver should see an invite in their DM.
428
- // Use a relationship user's ID for this.
429
- // activityManager
430
- // .SendInvite(
431
- // 364843917537050624,
432
- // Discord.ActivityActionType.Join,
433
- // "",
434
- // inviteResult =>
435
- // {
436
- // Console.WriteLine("Invite {0}", inviteResult);
437
- // }
438
- // );
439
- });
440
- }
441
- ```
442
-
443
- ## OnActivitySpectate
444
-
445
- Fires when a user accepts a spectate chat invite or clicks the Spectate button on a user's profile.
446
-
447
- ###### Parameters
448
-
449
- | name | type | description |
450
- | -------------- | ------ | ------------------------------------------------- |
451
- | spectateSecret | string | the secret to join the user's game as a spectator |
452
-
453
- ###### Example
454
-
455
- ```cs
456
- // Received when someone accepts a request to spectate
457
- activityManager.OnActivitySpectate += secret =>
458
- {
459
- Console.WriteLine("OnSpectate {0}", secret);
460
- };
461
- ```
462
-
463
- ## OnActivityJoinRequest
464
-
465
- Fires when a user asks to join the current user's game.
466
-
467
- ###### Parameters
468
-
469
- | name | type | description |
470
- | ---- | ---- | ----------------------- |
471
- | user | User | the user asking to join |
472
-
473
- ###### Example
474
-
475
- ```cs
476
- // A join request has been received. Render the request on the UI.
477
- activityManager.OnActivityJoinRequest += (ref Discord.User user) =>
478
- {
479
- Console.WriteLine("OnJoinRequest {0} {1}", user.Username, user.Id);
480
- };
481
- ```
482
-
483
- ## OnActivityInvite
484
-
485
- Fires when the user receives a join or spectate invite.
486
-
487
- ###### Parameters
488
-
489
- | name | type | description |
490
- | -------- | ------------------ | ------------------------------------------ |
491
- | type | ActivityActiontype | whether this invite is to join or spectate |
492
- | user | User | the user sending the invite |
493
- | activity | Activity | the inviting user's current activity |
494
-
495
- ###### Example
496
-
497
- ```cs
498
- // An invite has been received. Consider rendering the user / activity on the UI.
499
- activityManager.OnActivityInvite += (Discord.ActivityActionType Type, ref Discord.User user, ref Discord.Activity activity2) =>
500
- {
501
- Console.WriteLine("Recieved Invite Type: {0}, from User: {1}, with Activity Name: {2}", Type, user.Username, activity2.Name);
502
- // activityManager.AcceptInvite(user.Id, result =>
503
- // {
504
- // Console.WriteLine("AcceptInvite {0}", result);
505
- // });
506
- };
507
- ```
508
-
509
- ## Example: Inviting a User to a Game
510
-
511
- ```cs
512
- var discord = new Discord.Discord(clientId, Discord.CreateFlags.Default);
513
-
514
- // Update user's activity for your game.
515
- // Party and secrets are vital.
516
- var activity = new Discord.Activity
517
- {
518
- State = "olleh",
519
- Details = "foo details",
520
- Timestamps =
521
- {
522
- Start = 5,
523
- End = 6,
524
- },
525
- Assets =
526
- {
527
- LargeImage = "foo largeImageKey",
528
- LargeText = "foo largeImageText",
529
- SmallImage = "foo smallImageKey",
530
- SmallText = "foo smallImageText",
531
- },
532
- Party =
533
- {
534
- Id = "foo partyID",
535
- Size = {
536
- CurrentSize = 1,
537
- MaxSize = 4,
538
- },
539
- },
540
- Secrets =
541
- {
542
- Match = "foo matchSecret",
543
- Join = "foo joinSecret",
544
- Spectate = "foo spectateSecret",
545
- },
546
- Instance = true,
547
- };
548
-
549
- activityManager.UpdateActivity(activity, (result) =>
550
- {
551
- Console.WriteLine("Update Activity {0}", result);
552
-
553
- // Send an invite to another user for this activity.
554
- // Receiver should see an invite in their DM.
555
- // Use a relationship user's ID for this.
556
- activityManager.SendInvite(364843917537050999, Discord.ActivityActionType.Join, "", (inviteUserResult) =>
557
- {
558
- Console.WriteLine("Invite User {0}", inviteUserResult);
559
- });
560
- });
561
- ```