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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
use std::fmt;
use super::{id::UserId, user::User, utils::*};
#[derive(Clone, Deserialize, Serialize)]
#[non_exhaustive]
pub struct ApplicationInfo {
pub bot: Option<BotApplication>,
#[serde(default = "default_true")]
pub bot_public: bool,
pub bot_require_code_grant: bool,
pub description: String,
pub flags: Option<u64>,
pub icon: Option<String>,
pub id: UserId,
pub name: String,
pub redirect_uris: Vec<String>,
pub rpc_origins: Vec<String>,
pub team: Option<Vec<Team>>,
pub secret: String,
}
impl fmt::Debug for ApplicationInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ApplicationInfo")
.field("bot", &self.bot)
.field("bot_public", &self.bot_public)
.field("bot_require_code_grant", &self.bot_require_code_grant)
.field("description", &self.description)
.field("flags", &self.flags)
.field("icon", &self.icon)
.field("id", &self.id)
.field("name", &self.name)
.field("redirect_uris", &self.redirect_uris)
.field("rpc_origins", &self.rpc_origins)
.field("team", &self.team)
.finish()
}
}
#[derive(Clone, Deserialize, Serialize)]
#[non_exhaustive]
pub struct BotApplication {
pub id: UserId,
pub avatar: Option<String>,
#[serde(default)]
pub bot: bool,
pub discriminator: u16,
pub name: String,
pub token: String,
}
impl fmt::Debug for BotApplication {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BotApplication")
.field("id", &self.id)
.field("avatar", &self.avatar)
.field("bot", &self.bot)
.field("discriminator", &self.discriminator)
.field("name", &self.name)
.finish()
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PartialCurrentApplicationInfo {
pub id: UserId,
pub flags: u64,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[non_exhaustive]
pub struct CurrentApplicationInfo {
pub description: String,
pub icon: Option<String>,
pub id: UserId,
pub name: String,
pub owner: User,
#[serde(default)]
pub rpc_origins: Vec<String>,
pub bot_public: bool,
pub bot_require_code_grant: bool,
pub team: Option<Team>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Team {
pub icon: Option<String>,
#[serde(deserialize_with = "deserialize_u64")]
pub id: u64,
pub name: String,
pub members: Vec<TeamMember>,
pub owner_user_id: UserId,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TeamMember {
pub membership_state: MembershipState,
pub permissions: Vec<String>,
#[serde(deserialize_with = "deserialize_u64")]
pub team_id: u64,
pub user: User,
}
#[derive(Clone, Debug, Copy, PartialEq)]
pub enum MembershipState {
Invited = 1,
Accepted = 2,
Unknown = !0,
}
enum_number!(MembershipState {
Invited,
Accepted
});