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,289 +0,0 @@
1
- # Voice
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
- Discord's pride and joy is its voice chat. Well, ok, also its memes, but mostly the voice chat. Text and video chat are pretty great, too. And have you seen that store? Anyway.
10
-
11
- If you want people playing your game to be able to talk with each other, this Voice manager can help you out! Note that the main functionality for voice in this SDK is not _only_ in this manager. Connecting players to a voice chat happens with [ConnectVoice](#DOCS_GAME_SDK_LOBBIES/connectvoice) in the Lobby manager, and robust voice settings work through [OpenVoiceSettings](#DOCS_GAME_SDK_OVERLAY/openvoicesettings) in the Overlay manager. The Voice manager handles a few fine-grain details like self muting/deafening, swapping between VAD/PTT voice modes, and setting a PTT key. It's a subset of the robust settings from the overlay call for those of you that prefer to build UI and control things from your own game.
12
-
13
- ## Data Models
14
-
15
- ###### InputModeType Enum
16
-
17
- | name | value |
18
- | ------------- | ----- |
19
- | VoiceActivity | 0 |
20
- | PushToTalk | 1 |
21
-
22
- ###### InputMode Struct
23
-
24
- | name | type | description |
25
- | -------- | ------------- | --------------------------------------------- |
26
- | Type | InputModeType | set either VAD or PTT as the voice input mode |
27
- | Shortcut | string | the PTT hotkey for the user |
28
-
29
- ###### Shortcut Keys
30
-
31
- Keys can be mapped as a combination by adding a "+" between values, such as `"shift + 4"` or `"ctrl + v"`.
32
-
33
- | key type | value |
34
- | ------------- | --------------------------------------------------------- |
35
- | Alphabetical | "a", "b", "c", etc. |
36
- | Numerical | "1", "2", "3", etc. |
37
- | Symbols | "-", "+", ".", "/", etc. |
38
- | Function Keys | "f1", "f2", "f3", etc. |
39
- | Gamepads | standard XInput api values - "GAMEPAD0", "GAMEPAD1", etc. |
40
- | Enter | "enter" |
41
- | Tab | "tab" |
42
- | Spacebar | "space" |
43
- | Backspace | "backspace" |
44
- | Escape | "esc" |
45
- | Meta | "meta" |
46
- | Shift | "shift" |
47
- | Caps Lock | "caps lock" |
48
- | Alt | "alt" |
49
- | Control | "ctrl" |
50
- | Right Shift | "right shift" |
51
- | Right Alt | "right alt" |
52
- | Right Control | "right ctrl" |
53
- | Right Meta | "right meta" |
54
- | Page Up | "page up" |
55
- | Page Down | "page down" |
56
- | Scroll Lock | "scroll lock" |
57
- | Print Screen | "print screen" |
58
- | Rewind | "rewind" |
59
- | Play | "play" |
60
- | Fast Forward | "fast forward" |
61
- | Delete | "del" |
62
- | End | "end" |
63
- | Insert | "insert" |
64
- | Break | "break" |
65
- | Home | "home" |
66
- | Up Arrow | "up" |
67
- | Down Arrow | "down" |
68
- | Left Arrow | "left" |
69
- | Right Arrow | "right" |
70
-
71
- ## GetInputMode
72
-
73
- Get the current voice input mode for the user.
74
-
75
- Returns a `Discord.InputMode`.
76
-
77
- ###### Parameters
78
-
79
- None
80
-
81
- ###### Example
82
-
83
- ```cs
84
- var voiceManager = discord.GetVoiceManager();
85
- var inputMode = voiceManager.GetInputMode();
86
- Console.WriteLine("The current input mode is {0}. The current PTT hotkey is set to {1}", inputMode.Type, inputMode.Shortcut);
87
- ```
88
-
89
- ## SetInputMode
90
-
91
- Sets a new voice input mode for the user. Refer to [Shortcut Keys](#DOCS_GAME_SDK_DISCORD_VOICE/data-models-shortcut-keys) for a table of valid values for shortcuts.
92
-
93
- Returns a `Discord.Result` via callback.
94
-
95
- ###### Parameters
96
-
97
- | name | type | description |
98
- | --------- | --------- | ------------------------------- |
99
- | inputMode | InputMode | the new input mode for the user |
100
-
101
- ###### Example
102
-
103
- ```cs
104
- var voiceManager = discord.GetVoiceManager();
105
- var newMode = new Discord.InputMode()
106
- {
107
- Type = Discord.InputModeType.PushToTalk,
108
- Shortcut = "ctrl"
109
- };
110
- voiceManager.SetInputMode(newMode, (res) =>
111
- {
112
- if (res == Discord.Result.Ok)
113
- {
114
- Console.WriteLine("New input mode set");
115
- }
116
- });
117
- ```
118
-
119
- ## IsSelfMute
120
-
121
- Whether the connected user is currently muted.
122
-
123
- Returns `bool`.
124
-
125
- ###### Parameters
126
-
127
- None
128
-
129
- ###### Example
130
-
131
- ```cs
132
- var voiceManager = discord.GetVoiceManager();
133
- if (voiceManager.IsSelfMute())
134
- {
135
- Console.WriteLine("You are muted");
136
- }
137
- ```
138
-
139
- ## SetSelfMute
140
-
141
- Mutes or unmutes the currently connected user.
142
-
143
- Returns `void`.
144
-
145
- ###### Parameters
146
-
147
- | name | type | description |
148
- | ---- | ---- | ------------------------------- |
149
- | mute | bool | true for mute, false for unmute |
150
-
151
- ###### Example
152
-
153
- ```cs
154
- var voiceManager = discord.GetVoiceManager();
155
- if (voiceManager.IsSelfMute())
156
- {
157
- voiceManager.SetSelfMute(false);
158
- Console.WriteLine("We automatically unmuted you");
159
- }
160
- ```
161
-
162
- ## IsSelfDeaf
163
-
164
- Whether the connected user is currently deafened.
165
-
166
- Returns `bool`.
167
-
168
- ###### Parameters
169
-
170
- None
171
-
172
- ###### Example
173
-
174
- ```cs
175
- var voiceManager = discord.GetVoiceManager();
176
- if (voiceManager.IsSelfDeaf())
177
- {
178
- Console.WriteLine("You are deafened. You can't hear anyone!");
179
- }
180
- ```
181
-
182
- ## SetSelfDeaf
183
-
184
- Deafens or undefeans the currently connected user.
185
-
186
- Returns `void`.
187
-
188
- ###### Parameters
189
-
190
- | name | type | description |
191
- | ---- | ---- | ------------------------------- |
192
- | deaf | bool | true for mute, false for unmute |
193
-
194
- ###### Example
195
-
196
- ```cs
197
- var voiceManager = discord.GetVoiceManager();
198
- if (voiceManager.IsSelfDeaf())
199
- {
200
- voiceManager.SetSelfDeaf(false);
201
- Console.WriteLine("We automatically undeafened you. You can hear now!");
202
- }
203
- ```
204
-
205
- ## IsLocalMute
206
-
207
- Whether the given user is currently muted by the connected user.
208
-
209
- Returns `bool`.
210
-
211
- ###### Parameters
212
-
213
- | name | type | description |
214
- | ------ | ----- | --------------------------- |
215
- | userId | Int64 | the id of the user to check |
216
-
217
- ###### Example
218
-
219
- ```cs
220
- var voiceManager = discord.GetVoiceManager();
221
- if (voiceManager.IsLocalMute(53908232506183680))
222
- {
223
- Console.WriteLine("User is locally muted");
224
- }
225
- ```
226
-
227
- ## SetLocalMute
228
-
229
- Mutes or unmutes the given user for the currently connected user.
230
-
231
- Returns `void`.
232
-
233
- ###### Parameters
234
-
235
- | name | type | description |
236
- | ------ | ----- | ------------------------------- |
237
- | userId | Int64 | the id of the user to mute |
238
- | mute | bool | true for mute, false for unmute |
239
-
240
- ###### Example
241
-
242
- ```cs
243
- var voiceManager = discord.GetVoiceManager();
244
- if (!voiceManager.IsLocalMute(53908232506183680))
245
- {
246
- voiceManager.SetLocalMute(53908232506183680, true);
247
- Console.WriteLine("Muted that user for you");
248
- }
249
- ```
250
-
251
- ## GetLocalVolume
252
-
253
- Gets the local volume for a given user. This is the volume level at which the currently connected users hears the given user speak.
254
-
255
- Returns `byte`.
256
-
257
- ###### Parameters
258
-
259
- | name | type | description |
260
- | ------ | ----- | --------------------------- |
261
- | userId | Int64 | the id of the user to check |
262
-
263
- ###### Example
264
-
265
- ```cs
266
- var voiceManager = discord.GetVoiceManager();
267
- var volume = voiceManager.GetLocalVolume(53908232506183680);
268
- Console.WriteLine("User is at volume level {0}", volume);
269
- ```
270
-
271
- ## SetLocalVolume
272
-
273
- Sets the local volume for a given user. This is the volume level at which the currently connected users hears the given user speak. Valid volume values are from `0` to `200`, with `100` being the default. Lower than `100` will be a reduced volume level from default, whereas over `100` will be a boosted volume level from default.
274
-
275
- Returns `void`.
276
-
277
- ###### Parameters
278
-
279
- | name | type | description |
280
- | ------ | ----- | ------------------------------------------------- |
281
- | userId | Int64 | the id of the user to change |
282
- | volume | byte | the volume at which to set the user, `0` to `200` |
283
-
284
- ###### Example
285
-
286
- ```cs
287
- var voiceManager = discord.GetVoiceManager();
288
- voiceManager.SetLocalVolume(53908232506183680, 70);
289
- ```
@@ -1,196 +0,0 @@
1
- # Images
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
- Discord is like a book; it's better with pictures. The image manager helps you fetch image data for images in Discord, including user's avatars. They worked hard to pick out those photos and gifs. Show them you care, too.
10
-
11
- ## Data Models
12
-
13
- ###### ImageDimensions Struct
14
-
15
- | name | type | description |
16
- | ------ | ------ | ----------------------- |
17
- | Width | UInt32 | the width of the image |
18
- | Height | UInt32 | the height of the image |
19
-
20
- ###### ImageType Enum
21
-
22
- | value | description |
23
- | ----- | ------------------------ |
24
- | User | image is a user's avatar |
25
-
26
- ###### ImageHandle Struct
27
-
28
- | name | type | description |
29
- | ---- | --------- | ----------------------------------------------- |
30
- | Type | ImageType | the source of the image |
31
- | Id | Int64 | the id of the user whose avatar you want to get |
32
- | Size | UInt32 | the resolution at which you want the image |
33
-
34
- ## Fetch
35
-
36
- Prepares an image to later retrieve data about it.
37
-
38
- Returns a `Discord.Result` and `Discord.ImageHandle` via callback.
39
-
40
- ###### Parameters
41
-
42
- | name | type | description |
43
- | ------- | ----------- | ----------------------------------------------------------- |
44
- | handle | ImageHandle | contains the desired userId and size for the returned image |
45
- | refresh | bool | whether to use cached data for fetch anew |
46
-
47
- ###### Example
48
-
49
- ```cs
50
- var handle = new Discord.ImageHandle()
51
- {
52
- Id = 53908232506183680,
53
- Size = 1024
54
- };
55
-
56
- imageManager.Fetch(handle, false, (result, returnedHandle) =>
57
- {
58
- if (result == Discord.Result.Ok)
59
- {
60
- var data = imageManager.GetData(returnedHandle);
61
- // Do stuff with the byte[] data
62
- }
63
- });
64
- ```
65
-
66
- ## GetDimensions
67
-
68
- Gets the dimensions for the given user's avatar's source image.
69
-
70
- Returns `Discord.ImageDimensions`.
71
-
72
- ###### Parameters
73
-
74
- | name | type | description |
75
- | ------ | ----------- | ----------------------------------------------------------- |
76
- | handle | ImageHandle | contains the desired userId and size for the returned image |
77
-
78
- ###### Example
79
-
80
- ```cs
81
- var handle = new Discord.ImageHandle()
82
- {
83
- Id = 53908232506183680,
84
- Size = 1024
85
- };
86
- var dimensions = imageManager.GetDimensions(handle);
87
- ```
88
-
89
- ## GetData
90
-
91
- Gets the image data for a given user's avatar. In C#, this is overloaded by a helper function that will directly return a `byte[]` with the image data in it. In C++/C, this function reads image data into a passed pointer of defined size.
92
-
93
- ###### Parameters
94
-
95
- | name | type | description |
96
- | ------ | ----------- | --------------------------------------------- |
97
- | handle | ImageHandle | the image handle from the `Fetch()` callback |
98
- | data | uint8_t\* | a buffer to read image data into (C++/C only) |
99
- | size | uint | the size of the buffer (C++/C only) |
100
-
101
- ###### Example
102
-
103
- ```cs
104
- var handle = new Discord.ImageHandle()
105
- {
106
- Id = 53908232506183680,
107
- Size = 1024
108
- };
109
-
110
- imageManager.Fetch(handle, false, (result, handle) =>
111
- {
112
- if (result == Discord.Result.Ok)
113
- {
114
- var data = imageManager.GetData(handle);
115
- // Do stuff with data now
116
- }
117
- });
118
- ```
119
-
120
- ###### Example Cpp
121
-
122
- ```cpp
123
- core->ImageManager().Fetch(
124
- handle, true, [&state](discord::Result res, discord::ImageHandle handle) {
125
- if (res == discord::Result::Ok) {
126
- discord::ImageDimensions dims{};
127
- state.core->ImageManager().GetDimensions(handle, &dims);
128
- std::cout << "Fetched " << dims.GetWidth() << "x" << dims.GetHeight()
129
- << " avatar!\n";
130
-
131
- std::vector<uint8_t> data;
132
- data.reserve(dims.GetWidth() * dims.GetHeight() * 4);
133
- uint8_t* d = data.data();
134
- state.core->ImageManager().GetData(handle, d, data.size());
135
- }
136
- }
137
- );
138
- ```
139
-
140
- ## GetTexture
141
-
142
- > warn
143
- > This is only exposed in Unity
144
-
145
- Gets the `Texture2D` for a given user's avatar for use within a Unity environment.
146
-
147
- Returns a `Texture2D`.
148
-
149
- ###### Parameters
150
-
151
- | name | type | description |
152
- | ------ | ----------- | -------------------------------------------- |
153
- | handle | ImageHandle | the image handle from the `Fetch()` callback |
154
-
155
- ###### Example
156
-
157
- ```cs
158
- var handle = new Discord.ImageHandle()
159
- {
160
- Id = 53908232506183680,
161
- Size = 1024
162
- };
163
-
164
- imageManager.Fetch(handle, false, (result, handle) =>
165
- {
166
- if (result == Discord.Result.Ok)
167
- {
168
- var texture = imageManager.GetTexture(handle);
169
- // Do stuff with texture now
170
- }
171
- });
172
- ```
173
-
174
- ## Example: User's Avatar Data
175
-
176
- ```cs
177
- var discord = new Discord.Discord(clientId, Discord.CreateFlags.Default);
178
-
179
- // Request user's avatar data. Sizes can be powers of 2 between 16 and 2048
180
- imageManager.Fetch(Discord.ImageHandle.User(53908232506183680, 128), (result, handle) =>
181
- {
182
- {
183
- if (result == Discord.Result.Ok)
184
- {
185
- // If you are working in Unity, you can also use GetTexture()
186
- // Which is only exposed for Unity builds
187
- // These return raw RGBA.
188
- var data = imageManager.GetData(handle);
189
- }
190
- else
191
- {
192
- Console.WriteLine("image error {0}", handle.Id);
193
- }
194
- }
195
- };
196
- ```