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
use crate::{snowflake, util};
use chrono::{DateTime, Utc};
use serde::Deserialize;
/// A struct representing a user's social links.
#[derive(Clone, Debug, Deserialize)]
pub struct Socials {
/// A URL of this user's GitHub account.
#[serde(default, deserialize_with = "util::deserialize_optional_string")]
pub github: Option<String>,
/// A URL of this user's Instagram account.
#[serde(default, deserialize_with = "util::deserialize_optional_string")]
pub instagram: Option<String>,
/// A URL of this user's Reddit account.
#[serde(default, deserialize_with = "util::deserialize_optional_string")]
pub reddit: Option<String>,
/// A URL of this user's Twitter account.
#[serde(default, deserialize_with = "util::deserialize_optional_string")]
pub twitter: Option<String>,
/// A URL of this user's YouTube channel.
#[serde(default, deserialize_with = "util::deserialize_optional_string")]
pub youtube: Option<String>,
}
util::debug_struct! {
/// A struct representing a user logged into [Top.gg](https://top.gg).
#[must_use]
#[derive(Clone, Deserialize)]
User {
public {
/// The Discord ID of this user.
#[serde(deserialize_with = "snowflake::deserialize")]
id: u64,
/// The username of this user.
username: String,
/// The user's bio.
#[serde(default, deserialize_with = "util::deserialize_optional_string")]
bio: Option<String>,
/// A URL of this user's profile banner image.
#[serde(default, deserialize_with = "util::deserialize_optional_string")]
banner: Option<String>,
/// A struct of this user's social links.
#[serde(rename = "social")]
socials: Option<Socials>,
/// Whether this user is a [Top.gg](https://top.gg) supporter or not.
#[serde(rename = "supporter")]
is_supporter: bool,
/// Whether this user is a [Top.gg](https://top.gg) certified developer or not.
#[serde(rename = "certifiedDev")]
is_certified_dev: bool,
/// Whether this user is a [Top.gg](https://top.gg) moderator or not.
#[serde(rename = "mod")]
is_moderator: bool,
/// Whether this user is a [Top.gg](https://top.gg) website moderator or not.
#[serde(rename = "webMod")]
is_web_moderator: bool,
/// Whether this user is a [Top.gg](https://top.gg) website administrator or not.
#[serde(rename = "admin")]
is_admin: bool,
}
private {
#[serde(default, deserialize_with = "util::deserialize_optional_string")]
avatar: Option<String>,
}
getters(self) {
/// Retrieves the creation date of this user.
#[must_use]
#[inline(always)]
created_at: DateTime<Utc> => {
util::get_creation_date(self.id)
}
/// Retrieves the Discord avatar URL of this user.
///
/// Its format will either be PNG or GIF if animated.
#[must_use]
#[inline(always)]
avatar: String => {
util::get_avatar(&self.avatar, self.id)
}
}
}
}
#[derive(Deserialize)]
pub(crate) struct Voted {
pub(crate) voted: u8,
}
util::debug_struct! {
/// A struct representing a user who has voted on a Discord bot listed on [Top.gg](https://top.gg). (See [`Client::get_voters`][crate::Client::get_voters])
#[must_use]
#[derive(Clone, Deserialize)]
Voter {
public {
/// The Discord ID of this user.
#[serde(deserialize_with = "snowflake::deserialize")]
id: u64,
/// The username of this user.
username: String,
}
private {
avatar: Option<String>,
}
getters(self) {
/// Retrieves the creation date of this user.
#[must_use]
#[inline(always)]
created_at: DateTime<Utc> => {
util::get_creation_date(self.id)
}
/// Retrieves the Discord avatar URL of this user.
///
/// Its format will either be PNG or GIF if animated.
#[must_use]
#[inline(always)]
avatar: String => {
util::get_avatar(&self.avatar, self.id)
}
}
}
}