hubbub/types/
user.rs

1use serde::{Deserialize, Serialize};
2use serde_repr::{Deserialize_repr, Serialize_repr};
3
4use super::Snowflake;
5
6#[derive(Deserialize, Serialize, Debug, Clone)]
7pub struct AvatarDecorationData {
8    pub asset: String,
9    pub sku_id: String,
10}
11
12#[derive(Deserialize, Serialize, Debug, Clone)]
13pub struct UserClan {
14    #[serde(rename = "identity_enabled")]
15    pub shown: bool,
16    pub badge: Option<String>,
17    pub identity_guild_id: Option<String>,
18    pub tag: Option<String>,
19}
20
21#[derive(Deserialize_repr, Serialize_repr, Debug, Eq, PartialEq, Clone)]
22#[repr(u8)]
23pub enum RelationshipType {
24    Friend = 1,
25    Bot = 2,
26    IncomingFriendRequest = 3,
27    OutgoingFriendRequest = 4,
28}
29
30#[derive(Deserialize, Serialize, Debug, Clone)]
31pub struct Relationship {
32    pub id: String,
33    pub nickname: Option<String>,
34    pub since: Option<String>,
35    #[serde(rename = "type")]
36    pub user_type: RelationshipType,
37}
38
39#[derive(Deserialize_repr, Serialize_repr, Debug, Eq, PartialEq, Clone)]
40#[repr(u8)]
41pub enum PremiumType {
42    None = 0,
43    NitroClassic = 1,
44    Nitro = 2,
45    NitroBasic = 3,
46}
47
48#[repr(u32)]
49pub enum UserFlags {
50    Staff = 1 << 0,
51    Partner = 1 << 1,
52    Hypesquad = 1 << 2,
53    BugHunterLvl1 = 1 << 3,
54    HypesquadBravery = 1 << 6,
55    HypesquadBrilliance = 1 << 7,
56    HypesquadBalance = 1 << 8,
57    EarlyNitroSupporter = 1 << 9,
58    TeamPseudoUser = 1 << 10,
59    BugHunterLvl2 = 1 << 14,
60    VerifiedBot = 1 << 16,
61    VerifiedDev = 1 << 17,
62    CertifiedMod = 1 << 18,
63    BotHTTPInteractions = 1 << 19, // bot uses only http interactions
64    ActiveDev = 1 << 22,
65}
66
67fn default_bot_value() -> bool {
68    false
69}
70#[derive(Deserialize, Serialize, Debug, Clone)]
71pub struct User {
72    pub id: Snowflake,
73    pub username: String,
74
75    pub global_name: Option<String>, // bots: application name
76
77    pub avatar: Option<String>, // avatar hash
78    pub avatar_decoration_data: Option<AvatarDecorationData>,
79
80    pub banner: Option<String>,    // banner hash
81    pub accent_color: Option<u32>, // hex color
82
83    pub locale: Option<String>,
84
85    #[serde(rename = "bot", default = "default_bot_value")]
86    pub is_bot: bool,
87    #[serde(rename = "system", default = "default_bot_value")]
88    pub is_system: bool,
89
90    // These two are oath2 "email" scope only
91    #[serde(rename = "verified")]
92    pub is_verified: Option<bool>,
93    pub email: Option<String>,
94
95    pub mfa_enabled: Option<bool>,
96
97    pub public_flags: Option<u32>,
98
99    pub premium_type: Option<PremiumType>,
100}
101
102#[derive(Deserialize, Serialize, Debug, Clone)]
103pub struct BotUser {
104    pub id: Snowflake,
105    pub username: String,
106    pub global_name: Option<String>,
107    pub pronouns: String,
108    pub bio: String,
109
110    pub avatar: Option<String>,
111    pub avatar_decoration_data: Option<AvatarDecorationData>,
112
113    pub banner: Option<String>,
114    pub banner_color: Option<String>,
115    pub accent_color: Option<u64>,
116
117    pub clan: Option<UserClan>,
118
119    #[serde(rename = "desktop")]
120    pub on_desktop: bool,
121    #[serde(rename = "mobile")]
122    pub on_mobile: bool,
123    #[serde(rename = "verified")]
124    pub is_verified: bool,
125    #[serde(rename = "premium")]
126    pub has_premium: bool,
127
128    pub email: Option<String>,
129    pub phone: Option<String>,
130
131    pub mfa_enabled: bool,
132    pub nsfw_allowed: bool,
133
134    pub premium_type: u32,
135
136    pub purchased_flags: u32,
137    pub public_flags: Option<u64>,
138    pub flags: u64,
139}