filthy_rich/types/
data.rs1use serde::Deserialize;
5use serde_json::Value;
6
7use crate::{ds, types::payloads::ActivityPayload};
8
9#[derive(Debug, Clone, Deserialize)]
17pub struct ActivityResponseData {
18 application_id: Option<String>,
19 platform: Option<String>,
20 metadata: Option<Value>,
21 #[serde(flatten)]
23 pub activity: ActivityPayload,
24}
25
26impl ActivityResponseData {
27 ds!(application_id, "The ID of the application");
28 ds!(platform, "The platform of the host.");
29
30 #[must_use]
31 pub fn metadata(&self) -> Option<&Value> {
32 self.metadata.as_ref()
33 }
34}
35
36#[derive(Debug, Clone, Deserialize)]
38pub struct ReadyData {
39 v: u8,
40 pub config: ServerConfigurationData,
42 pub user: DiscordUser,
44}
45
46impl ReadyData {
47 #[must_use]
49 pub fn version(&self) -> u8 {
50 self.v
51 }
52}
53
54#[derive(Debug, Clone, Deserialize)]
56pub struct ServerConfigurationData {
57 cdn_host: String,
58 api_endpoint: String,
59 environment: String,
60}
61
62impl ServerConfigurationData {
63 #[must_use]
65 pub fn cdn_host(&self) -> &str {
66 &self.cdn_host
67 }
68
69 #[must_use]
71 pub fn api_endpoint(&self) -> &str {
72 &self.api_endpoint
73 }
74
75 #[must_use]
77 pub fn environment(&self) -> &str {
78 &self.environment
79 }
80}
81
82#[derive(Debug, Clone, Deserialize)]
86pub struct DiscordUser {
87 id: String,
88 username: String,
89 discriminator: String,
90 global_name: Option<String>,
91 avatar: Option<String>,
92 bot: Option<bool>,
93 system: Option<bool>,
94 mfa_enabled: Option<bool>,
95 banner: Option<String>,
96 accent_color: Option<isize>,
97 locale: Option<String>,
98 verified: Option<bool>,
99 email: Option<String>,
100 flags: Option<isize>,
101 premium_type: Option<isize>,
102 public_flags: Option<isize>,
103 pub avatar_decoration_data: Option<AvatarDecorationData>,
105 pub collectibles: Option<Collectibles>,
107 pub primary_guild: Option<PrimaryGuild>,
109}
110
111impl DiscordUser {
112 #[must_use]
114 pub fn id(&self) -> &str {
115 &self.id
116 }
117
118 #[must_use]
120 pub fn username(&self) -> &str {
121 &self.username
122 }
123
124 #[must_use]
126 pub fn discriminator(&self) -> &str {
127 &self.discriminator
128 }
129
130 ds!(global_name, "The user's display name, if set.");
131 ds!(avatar, "The user's avatar hash.");
132
133 #[must_use]
135 pub fn bot(&self) -> Option<bool> {
136 self.bot
137 }
138
139 #[must_use]
141 pub fn system(&self) -> Option<bool> {
142 self.system
143 }
144
145 #[must_use]
147 pub fn mfa_enabled(&self) -> Option<bool> {
148 self.mfa_enabled
149 }
150
151 ds!(banner, "The user's banner hash.");
152 ds!(locale, "The user's chosen language option.");
153 ds!(email, "The user's email.");
154
155 #[must_use]
157 pub fn verified(&self) -> Option<bool> {
158 self.verified
159 }
160
161 #[must_use]
163 pub fn accent_color(&self) -> Option<isize> {
164 self.accent_color
165 }
166
167 #[must_use]
169 pub fn flags(&self) -> Option<isize> {
170 self.flags
171 }
172
173 #[must_use]
175 pub fn premium_type(&self) -> Option<isize> {
176 self.premium_type
177 }
178
179 #[must_use]
181 pub fn public_flags(&self) -> Option<isize> {
182 self.public_flags
183 }
184}
185
186#[derive(Debug, Clone, Deserialize)]
188pub struct AvatarDecorationData {
189 asset: String,
190 sku_id: String,
191}
192
193impl AvatarDecorationData {
194 #[must_use]
196 pub fn asset(&self) -> &str {
197 &self.asset
198 }
199 #[must_use]
201 pub fn sku_id(&self) -> &str {
202 &self.sku_id
203 }
204}
205
206#[derive(Debug, Clone, Deserialize)]
208pub struct Collectibles {
209 pub nameplate: Option<NameplateData>,
211}
212
213#[derive(Debug, Clone, Deserialize)]
214pub struct NameplateData {
215 sku_id: String,
216 asset: String,
217 label: String,
218 palette: String,
219}
220
221impl NameplateData {
222 #[must_use]
224 pub fn sku_id(&self) -> &str {
225 &self.sku_id
226 }
227 #[must_use]
229 pub fn asset(&self) -> &str {
230 &self.asset
231 }
232 #[must_use]
234 pub fn label(&self) -> &str {
235 &self.label
236 }
237 #[must_use]
240 pub fn palette(&self) -> &str {
241 &self.palette
242 }
243}
244
245#[derive(Debug, Clone, Deserialize)]
246pub struct PrimaryGuild {
247 identity_guild_id: Option<String>,
248 identity_enabled: Option<bool>,
249 tag: Option<String>,
250 badge: Option<String>,
251}
252
253impl PrimaryGuild {
254 ds!(identity_guild_id, "The ID of the user's primary guild.");
255 ds!(
256 tag,
257 "The text of the user's server tag. Limited to 4 characters."
258 );
259 ds!(badge, "The server tag badge hash.");
260
261 #[must_use]
265 pub fn identity_enabled(&self) -> Option<bool> {
266 self.identity_enabled
267 }
268}