discord-ferris 0.0.2

discord-ferris is a Discord API Rust library under development 🦀
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};

use super::guild::APIGuildIntegration;

/**
 * Types extracted from https://discord.com/developers/docs/resources/user
 */

/**
 * @see {@link https://discord.com/developers/docs/resources/user#user-object}
 */
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct APIUser {
    /**
     * The user's id
     */
    pub id: String,
    /**
     * The user's username, not unique across the platform
     */
    pub username: String,
    /**
     * The user's Discord-tag
     */
    pub discriminator: String,
    /**
     * The user's display name, if it is set. For bots, this is the application name
     */
    pub global_name: Option<String>,
    /**
     * The user's avatar hash
     *
     * @see {@link https://discord.com/developers/docs/reference#image-formatting}
     */
    pub avatar: Option<String>,
    /**
     * Whether the user belongs to an OAuth2 application
     */
    pub bot: Option<bool>,
    /**
     * Whether the user is an Official Discord System user (part of the urgent message system)
     */
    pub system: Option<bool>,
    /**
     * Whether the user has two factor enabled on their account
     */
    pub mfa_enabled: Option<bool>,
    /**
     * The user's banner hash
     *
     * @see {@link https://discord.com/developers/docs/reference#image-formatting}
     */
    pub banner: Option<String>,
    /**
     * The user's banner color encoded as an integer representation of hexadecimal color code
     */
    pub accent_color: Option<u64>,
    /**
     * The user's chosen language option
     */
    pub locale: Option<String>,
    /**
     * Whether the email on this account has been verified
     */
    pub verified: Option<bool>,
    /**
     * The user's email
     */
    pub email: Option<String>,
    /**
     * The flags on a user's account
     *
     * @see {@link https://discord.com/developers/docs/resources/user#user-object-user-flags}
     */
    pub flags: Option<u64>,
    /**
     * The type of Nitro subscription on a user's account
     *
     * @see {@link https://discord.com/developers/docs/resources/user#user-object-premium-types}
     */
    pub premium_type: Option<UserPremiumType>,
    /**
     * The public flags on a user's account
     *
     * @see {@link https://discord.com/developers/docs/resources/user#user-object-user-flags}
     */
    pub public_flags: Option<u64>,
    /**
     * The user's avatar decoration hash
     *
     * @see {@link https://discord.com/developers/docs/reference#image-formatting}
     * @deprecated Use {@link APIUser.avatar_decoration_data} instead
     */
    pub avatar_decoration: Option<String>,
    /**
     * The data for the user's avatar decoration
     *
     * @see {@link https://discord.com/developers/docs/resources/user#avatar-decoration-data-object}
     */
    pub avatar_decoration_data: Option<APIAvatarDecorationData>,
    /**
     * The data for the user's collectibles
     *
     * @see {@link https://discord.com/developers/docs/resources/user#collectibles}
     */
    pub collectibles: Option<APICollectibles>,
    /**
     * The user's primary guild
     *
     * @see {@link https://discord.com/developers/docs/resources/user#user-object-user-primary-guild}
     */
    pub primary_guild: Option<APIUserPrimaryGuild>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/user#user-object-user-flags}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[repr(u64)]
pub enum UserFlags {
    /**
     * Discord Employee
     */
    Staff = 1 << 0,
    /**
     * Partnered Server Owner
     */
    Partner = 1 << 1,
    /**
     * HypeSquad Events Member
     */
    Hypesquad = 1 << 2,
    /**
     * Bug Hunter Level 1
     */
    BugHunterLevel1 = 1 << 3,
    /**
     * @unstable This user flag is currently not documented by Discord but has a known value which we will try to keep up to date.
     */
    MFASMS = 1 << 4,
    /**
     * @unstable This user flag is currently not documented by Discord but has a known value which we will try to keep up to date.
     */
    PremiumPromoDismissed = 1 << 5,
    /**
     * House Bravery Member
     */
    HypeSquadOnlineHouse1 = 1 << 6,
    /**
     * House Brilliance Member
     */
    HypeSquadOnlineHouse2 = 1 << 7,
    /**
     * House Balance Member
     */
    HypeSquadOnlineHouse3 = 1 << 8,
    /**
     * Early Nitro Supporter
     */
    PremiumEarlySupporter = 1 << 9,
    /**
     * User is a {@link https://discord.com/developers/docs/topics/teams | team}
     */
    TeamPseudoUser = 1 << 10,
    /**
     * @unstable This user flag is currently not documented by Discord but has a known value which we will try to keep up to date.
     */
    HasUnreadUrgentMessages = 1 << 13,
    /**
     * Bug Hunter Level 2
     */
    BugHunterLevel2 = 1 << 14,
    /**
     * Verified Bot
     */
    VerifiedBot = 1 << 16,
    /**
     * Early Verified Bot Developer
     */
    VerifiedDeveloper = 1 << 17,
    /**
     * Moderator Programs Alumni
     */
    CertifiedModerator = 1 << 18,
    /**
     * Bot uses only {@link https://discord.com/developers/docs/interactions/receiving-and-responding#receiving-an-interaction | HTTP interactions} and is shown in the online member list
     */
    BotHTTPInteractions = 1 << 19,
    /**
     * User has been identified as spammer
     *
     * @unstable This user flag is currently not documented by Discord but has a known value which we will try to keep up to date.
     */
    Spammer = 1 << 20,
    /**
     * @unstable This user flag is currently not documented by Discord but has a known value which we will try to keep up to date.
     */
    DisablePremium = 1 << 21,
    /**
     * User is an {@link https://support-dev.discord.com/hc/articles/10113997751447 | Active Developer}
     */
    ActiveDeveloper = 1 << 22,
    /**
     * User's account has been {@link https://support.discord.com/hc/articles/6461420677527 | quarantined} based on recent activity
     *
     * @unstable This user flag is currently not documented by Discord but has a known value which we will try to keep up to date.
     * @privateRemarks
     *
     * This value would be `1 << 44`, but bit shifting above `1 << 30` requires bigints
     */
    Quarantined = 17_592_186_044_416,
    /**
     * @unstable This user flag is currently not documented by Discord but has a known value which we will try to keep up to date.
     * @privateRemarks
     *
     * This value would be `1 << 50`, but bit shifting above `1 << 30` requires bigints
     */
    Collaborator = 1_125_899_906_842_624,
    /**
     * @unstable This user flag is currently not documented by Discord but has a known value which we will try to keep up to date.
     * @privateRemarks
     *
     * This value would be `1 << 51`, but bit shifting above `1 << 30` requires bigints
     */
    RestrictedCollaborator = 2_251_799_813_685_248,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/user#user-object-premium-types}
 */
#[derive(Debug, Clone, PartialEq, Eq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum UserPremiumType {
    None = 0,
    NitroClassic = 1,
    Nitro = 2,
    NitroBasic = 3,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/user#connection-object}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIConnection {
    /**
     * ID of the connection account
     */
    pub id: String,
    /**
     * The username of the connection account
     */
    pub name: String,
    /**
     * The service of the connection
     *
     * @see {@link https://discord.com/developers/docs/resources/user#connection-object-services}
     */
    pub r#type: ConnectionService,
    /**
     * Whether the connection is revoked
     */
    pub revoked: Option<bool>,
    /**
     * An array of partial server integrations
     *
     * @see {@link https://discord.com/developers/docs/resources/guild#integration-object}
     */
    pub integrations: Option<Vec<APIGuildIntegration>>,
    /**
     * Whether the connection is verified
     */
    pub verified: bool,
    /**
     * Whether friend sync is enabled for this connection
     */
    pub friend_sync: bool,
    /**
     * Whether activities related to this connection will be shown in presence updates
     */
    pub show_activity: bool,
    /**
     * Whether this connection supports console voice transfer
     */
    pub two_way_link: bool,
    /**
     * Visibility of this connection
     *
     * @see {@link https://discord.com/developers/docs/resources/user#connection-object-visibility-types}
     */
    pub visibility: ConnectionVisibility,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ConnectionService {
    #[serde(rename = "amazon-music")]
    AmazonMusic,
    #[serde(rename = "battlenet")]
    BattleNet,
    #[serde(rename = "bluesky")]
    Bluesky,
    #[serde(rename = "bungie")]
    BungieNet,
    #[serde(rename = "crunchyroll")]
    Crunchyroll,
    #[serde(rename = "domain")]
    Domain,
    #[serde(rename = "ebay")]
    EBay,
    #[serde(rename = "epicgames")]
    EpicGames,
    #[serde(rename = "facebook")]
    Facebook,
    #[serde(rename = "github")]
    GitHub,
    #[serde(rename = "instagram")]
    Instagram,
    #[serde(rename = "leagueoflegends")]
    LeagueOfLegends,
    #[serde(rename = "mastodon")]
    Mastodon,
    #[serde(rename = "paypal")]
    PayPal,
    #[serde(rename = "playstation")]
    PlayStationNetwork,
    #[serde(rename = "reddit")]
    Reddit,
    #[serde(rename = "riotgames")]
    RiotGames,
    #[serde(rename = "roblox")]
    Roblox,
    #[serde(rename = "spotify")]
    Spotify,
    #[serde(rename = "skype")]
    Skype,
    #[serde(rename = "steam")]
    Steam,
    #[serde(rename = "tiktok")]
    TikTok,
    #[serde(rename = "twitch")]
    Twitch,
    #[serde(rename = "twitter")]
    X,
    #[serde(rename = "xbox")]
    Xbox,
    #[serde(rename = "youtube")]
    YouTube,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize_repr, Deserialize_repr)]
#[repr(u8)]
pub enum ConnectionVisibility {
    /**
     * Invisible to everyone except the user themselves
     */
    None = 0,
    /**
     * Visible to everyone
     */
    Everyone = 1,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/user#application-role-connection-object-application-role-connection-structure}
 */
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct APIApplicationRoleConnection {
    /**
     * The vanity name of the platform a bot has connected (max 50 characters)
     */
    pub platform_name: Option<String>,
    /**
     * The username on the platform a bot has connected (max 100 characters)
     */
    pub platform_username: Option<String>,
    /**
     * Object mapping application role connection metadata keys to their `string`-ified value (max 100 characters) for the user on the platform a bot has connected
     */
    pub metadata: std::collections::HashMap<String, serde_json::Value>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/user#avatar-decoration-data-object}
 */
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct APIAvatarDecorationData {
    /**
     * The avatar decoration hash
     *
     * @see {@link https://discord.com/developers/docs/reference#image-formatting}
     */
    pub asset: String,
    /**
     * The id of the avatar decoration's SKU
     */
    pub sku_id: String,
}

/**
 * The collectibles the user has, excluding Avatar Decorations and Profile Effects.
 *
 * @see {@link https://discord.com/developers/docs/resources/user#collectibles}
 */
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct APICollectibles {
    /**
     * Object mapping of {@link APINameplateData}
     */
    pub nameplate: Option<APINameplateData>,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/user#nameplate}
 */
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct APINameplateData {
    /**
     * ID of the nameplate SKU
     */
    pub sku_id: String,
    /**
     * Path to the nameplate asset
     *
     * @example `nameplates/nameplates/twilight/`
     */
    pub asset: String,
    /**
     * The label of this nameplate. Currently unused
     */
    pub label: String,
    /**
     * Background color of the nameplate
     */
    pub palette: NameplatePalette,
}

/**
 * Background color of a nameplate.
 */
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum NameplatePalette {
    #[serde(rename = "berry")]
    Berry,
    #[serde(rename = "bubble_gum")]
    BubbleGum,
    #[serde(rename = "clover")]
    Clover,
    #[serde(rename = "cobalt")]
    Cobalt,
    #[serde(rename = "crimson")]
    Crimson,
    #[serde(rename = "forest")]
    Forest,
    #[serde(rename = "lemon")]
    Lemon,
    #[serde(rename = "sky")]
    Sky,
    #[serde(rename = "teal")]
    Teal,
    #[serde(rename = "violet")]
    Violet,
    #[serde(rename = "white")]
    White,
}

/**
 * @see {@link https://discord.com/developers/docs/resources/user#user-object-user-primary-guild}
 */
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct APIUserPrimaryGuild {
    /**
     * The id of the user's primary guild
     */
    pub identity_guild_id: Option<String>,
    /**
     * Whether the user is displaying the primary guild's server tag.
     * This can be `null` if the system clears the identity, e.g. because the server no longer supports tags
     */
    pub identity_enabled: Option<bool>,
    /**
     * The text of the user's server tag. Limited to 4 characters
     */
    pub tag: Option<String>,
    /**
     * The server tag badge hash
     *
     * @see {@link https://discord.com/developers/docs/reference#image-formatting}
     */
    pub badge: Option<String>,
}