1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use crate::attachment::Attachment;
6
7#[derive(Deserialize, Debug, Clone, PartialEq)]
9pub enum RelationshipStatus {
10 None,
11 User,
12 Friend,
13 Outgoing,
14 Incoming,
15 Blocked,
16 BlockedOther,
17}
18
19#[derive(Deserialize, Debug, Clone)]
21pub struct Relationship {
22 #[serde(rename = "_id")]
23 pub id: String,
24 pub status: RelationshipStatus,
25}
26
27#[derive(Deserialize, Debug, Clone)]
29pub struct Mutuals {
30 pub users: Vec<String>,
32 pub servers: Vec<String>,
34}
35
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
38pub enum Presence {
39 Online,
41 Idle,
43 Focus,
45 Busy,
47 Invisible,
49}
50
51#[derive(Serialize, Deserialize, Debug, Clone, Default)]
53pub struct UserStatus {
54 #[serde(skip_serializing_if = "Option::is_none")]
56 pub text: Option<String>,
57 #[serde(skip_serializing_if = "Option::is_none")]
59 pub presence: Option<Presence>,
60}
61
62#[derive(Deserialize, Debug, Clone, Default)]
64pub struct UserProfile {
65 pub content: Option<String>,
67 pub background: Option<Attachment>,
69}
70
71#[derive(Serialize, Deserialize, Debug, Clone)]
75pub struct PartialUserProfile {
76 #[serde(skip_serializing_if = "Option::is_none")]
78 content: Option<String>,
79 #[serde(skip_serializing_if = "Option::is_none")]
81 background: Option<String>,
82}
83
84bitflags::bitflags! {
85 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
87 pub struct Badges: u64 {
88 const Developer = 1 << 0;
90 const Translator = 1 << 1;
92 const Supporter = 1 << 2;
94 const ResponsibleDisclosure = 1 << 3;
96 const Founder = 1 << 4;
98 const PlatformModeration = 1 << 5;
100 const ActiveSupporter = 1 << 6;
102 const Paw = 1 << 7;
104 const EarlyAdopter = 1 << 8;
106 const ReservedRelevantJokeBadge1 = 1 << 9;
108 const ReservedRelevantJokeBadge2 = 1 << 10;
110 }
111}
112crate::impl_serde_bitflags!(Badges);
113
114bitflags::bitflags! {
115 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
117 pub struct UserFlags: u64 {
118 const Suspended = 1;
120 const Deleted = 2;
122 const Banned = 4;
124 const Spam = 8;
126 }
127}
128crate::impl_serde_bitflags!(UserFlags);
129
130#[derive(Deserialize, Debug, Clone)]
132pub struct BotInformation {
133 pub owner: String,
135}
136
137#[derive(Deserialize, Debug, Clone)]
139pub struct User {
140 #[serde(rename = "_id")]
142 pub id: String,
143 pub username: String,
145 pub discriminator: String,
147 pub display_name: Option<String>,
149 pub avatar: Option<Attachment>,
151 pub relations: Option<Vec<Relationship>>,
153
154 pub badges: Option<i32>,
156 pub status: Option<UserStatus>,
158 pub profile: Option<UserProfile>,
160
161 pub flags: Option<UserFlags>,
163 #[serde(default)]
165 pub privileged: bool,
166 pub bot: Option<BotInformation>,
168
169 pub relationship: Option<RelationshipStatus>,
171 pub online: Option<bool>,
173}
174
175#[derive(Deserialize, Debug, Clone)]
177pub struct PartialUser {
178 #[serde(rename = "_id")]
180 pub id: Option<String>,
181 pub username: Option<String>,
183 pub discriminator: Option<String>,
185 pub display_name: Option<String>,
187 pub avatar: Option<Attachment>,
189 pub relations: Option<Vec<Relationship>>,
191
192 pub badges: Option<i32>,
194 pub status: Option<UserStatus>,
196 pub profile: Option<UserProfile>,
198
199 pub flags: Option<UserFlags>,
201 pub privileged: Option<bool>,
203 pub bot: Option<BotInformation>,
205
206 pub relationship: Option<RelationshipStatus>,
208 pub online: Option<bool>,
210}
211
212#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
214pub enum FieldsUser {
215 Avatar,
216 StatusText,
217 StatusPresence,
218 ProfileContent,
219 ProfileBackground,
220 DisplayName,
221}
222
223pub type UserSettings = HashMap<String, (i64, String)>;