1use serde::Deserialize;
5use serde_json::Value;
6
7use crate::{ds, str, 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 str!(cdn_host, "The CDN for the RPC server.");
64 str!(api_endpoint, "The API endpoint for the RPC server.");
65 str!(environment, "The environment for the RPC server.");
66}
67
68#[derive(Debug, Clone, Deserialize)]
72pub struct DiscordUser {
73 id: String,
74 username: String,
75 discriminator: String,
76 global_name: Option<String>,
77 avatar: Option<String>,
78 bot: Option<bool>,
79 system: Option<bool>,
80 mfa_enabled: Option<bool>,
81 banner: Option<String>,
82 accent_color: Option<isize>,
83 locale: Option<String>,
84 verified: Option<bool>,
85 email: Option<String>,
86 flags: Option<isize>,
87 premium_type: Option<isize>,
88 public_flags: Option<isize>,
89 pub avatar_decoration_data: Option<AvatarDecorationData>,
91 pub collectibles: Option<Collectibles>,
93 pub primary_guild: Option<PrimaryGuild>,
95}
96
97impl DiscordUser {
98 str!(id, "The user's ID.");
99 str!(
100 username,
101 "The user's username, not unique across the platform."
102 );
103 str!(discriminator, "The user's Discord-tag.");
104
105 ds!(global_name, "The user's display name, if set.");
106 ds!(avatar, "The user's avatar hash.");
107
108 #[must_use]
110 pub fn bot(&self) -> Option<bool> {
111 self.bot
112 }
113
114 #[must_use]
116 pub fn system(&self) -> Option<bool> {
117 self.system
118 }
119
120 #[must_use]
122 pub fn mfa_enabled(&self) -> Option<bool> {
123 self.mfa_enabled
124 }
125
126 ds!(banner, "The user's banner hash.");
127 ds!(locale, "The user's chosen language option.");
128 ds!(email, "The user's email.");
129
130 #[must_use]
132 pub fn verified(&self) -> Option<bool> {
133 self.verified
134 }
135
136 #[must_use]
138 pub fn accent_color(&self) -> Option<isize> {
139 self.accent_color
140 }
141
142 #[must_use]
144 pub fn flags(&self) -> Option<isize> {
145 self.flags
146 }
147
148 #[must_use]
150 pub fn premium_type(&self) -> Option<isize> {
151 self.premium_type
152 }
153
154 #[must_use]
156 pub fn public_flags(&self) -> Option<isize> {
157 self.public_flags
158 }
159}
160
161#[derive(Debug, Clone, Deserialize)]
163pub struct AvatarDecorationData {
164 asset: String,
165 sku_id: String,
166}
167
168impl AvatarDecorationData {
169 str!(
170 asset,
171 "The avatar decoration hash. See: <https://docs.discord.com/developers/reference#image-formatting>"
172 );
173 str!(sku_id, "ID of the avatar decoration's SKU.");
174}
175
176#[derive(Debug, Clone, Deserialize)]
178pub struct Collectibles {
179 pub nameplate: Option<NameplateData>,
181}
182
183#[derive(Debug, Clone, Deserialize)]
184pub struct NameplateData {
185 sku_id: String,
186 asset: String,
187 label: String,
188 palette: String,
189}
190
191impl NameplateData {
192 str!(sku_id, "ID of the nameplate SKU.");
193 str!(
194 asset,
195 "Path to the nameplate asset. See: <https://docs.discord.com/developers/reference#image-formatting>"
196 );
197 str!(label, "The label of this nameplate. Currently unused.");
198 str!(
199 palette,
200 "Background color of the nameplate, one of: `crimson`, `berry`, `sky`, `teal`, `forest`, `bubble_gum`, `violet`, `cobalt`, `clover`, `lemon`, `white`"
201 );
202}
203
204#[derive(Debug, Clone, Deserialize)]
205pub struct PrimaryGuild {
206 identity_guild_id: Option<String>,
207 identity_enabled: Option<bool>,
208 tag: Option<String>,
209 badge: Option<String>,
210}
211
212impl PrimaryGuild {
213 ds!(identity_guild_id, "The ID of the user's primary guild.");
214 ds!(
215 tag,
216 "The text of the user's server tag. Limited to 4 characters."
217 );
218 ds!(badge, "The server tag badge hash.");
219
220 #[must_use]
224 pub fn identity_enabled(&self) -> Option<bool> {
225 self.identity_enabled
226 }
227}