adiscord_types/api/guild.rs
1use crate::Snowflake;
2use super::{emoji::Emoji, feature::Feature, role::Role, sticker::Sticker, user::User};
3use serde::{Deserialize, Serialize};
4use serde_repr::{Deserialize_repr, Serialize_repr};
5
6#[repr(u8)]
7#[allow(non_camel_case_types)]
8#[derive(Deserialize_repr, Serialize_repr, Debug)]
9pub enum MemberFlags {
10 None,
11
12 /// Member has left and rejoined the guild
13 DID_REJOIN = 1 << 0,
14
15 /// Member has completed onboarding
16 COMPLETED_ONBOARDING = 1 << 1,
17
18 /// Member is exempt from guild verification requirements
19 BYPASSES_VERIFICATION = 1 << 2,
20
21 /// Member has started onboarding
22 STARTED_ONBOARDING = 1 << 3,
23}
24
25#[derive(Deserialize, Serialize, Debug)]
26pub struct Member {
27 /// the user this guild member represents
28 pub user: Option<User>,
29
30 /// this user's guild nickname
31 pub nick: Option<String>,
32
33 /// the member's guild avatar hash
34 pub avatar: Option<String>,
35
36 /// array of role object ids
37 pub roles: Vec<String>,
38
39 /// when the user joined the guild
40 pub joined_at: String,
41
42 /// when the user started boosting the guild
43 pub premium_since: Option<String>,
44
45 /// whether the user is deafened in voice channels
46 pub deaf: bool,
47
48 /// whether the user is muted in voice channels
49 pub mute: bool,
50
51 /// guild member flags represented as a bit set, defaults to 0
52 pub flags: MemberFlags,
53
54 /// whether the user has not yet passed the guild's Membership Screening requirements
55 pub pending: Option<bool>,
56
57 /// total permissions of the member in the channel, including overwrites, returned when in the interaction object
58 pub permissions: Option<String>,
59
60 /// when the user's timeout will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out
61 pub communication_disabled_until: Option<String>,
62}
63
64#[derive(Deserialize, Serialize, Debug)]
65pub struct Channels {
66 /// the channel's id
67 pub channel_id: Snowflake,
68
69 /// the description shown for the channel
70 pub description: String,
71
72 /// the emoji id, if the emoji is custom
73 pub emoji_id: Snowflake,
74
75 /// the emoji name if custom, the unicode character if standard, or null if no emoji is set
76 pub emoji_name: String,
77}
78
79#[derive(Deserialize, Serialize, Debug)]
80pub struct WelcomeScreen {
81 /// the server description shown in the welcome screen
82 pub description: String,
83
84 /// the channels shown in the welcome screen, up to 5
85 pub welcome_channels: Vec<Channels>,
86}
87
88#[repr(u8)]
89#[allow(non_camel_case_types)]
90#[derive(Deserialize_repr, Serialize_repr, Debug)]
91pub enum DefaultMessageNotifications {
92 /// members will receive notifications for all messages by default
93 ALL_MESSAGES,
94
95 /// members will receive notifications only for messages that @mention them by default
96 ONLY_MENTIONS,
97}
98
99#[repr(u8)]
100#[allow(non_camel_case_types)]
101#[derive(Deserialize_repr, Serialize_repr, Debug)]
102pub enum ExplicitContentFilter {
103 /// media content will not be scanned
104 DISABLED,
105
106 /// media content sent by members without roles will be scanned
107 MEMBERS_WITHOUT_ROLES,
108
109 /// media content sent by all members will be scanned
110 ALL_MEMBERS,
111}
112
113#[repr(u8)]
114#[derive(Deserialize_repr, Serialize_repr, Debug)]
115pub enum MFALevel {
116 /// guild has no MFA/2FA requirement for moderation actions
117 None,
118
119 /// guild has a 2FA requirement for moderation actions
120 Elevated,
121}
122
123#[repr(u8)]
124#[derive(Deserialize_repr, Serialize_repr, Debug)]
125pub enum NSFWLevel {
126 Default,
127 Explicit,
128 Safe,
129 AgeRestricted,
130}
131
132#[repr(u8)]
133#[derive(Deserialize_repr, Serialize_repr, Debug)]
134pub enum PremiumTier {
135 /// guild has not unlocked any Server Boost perks
136 None,
137
138 /// guild has unlocked Server Boost level 1 perks
139 Tier1,
140
141 /// guild has unlocked Server Boost level 2 perks
142 Tier2,
143
144 /// guild has unlocked Server Boost level 3 perks
145 Tier3,
146}
147
148#[derive(Deserialize, Serialize, Debug)]
149pub struct Preview {
150 /// guild id
151 pub id: Snowflake,
152
153 /// guild name (2-100 characters, excluding trailing and leading whitespace)
154 pub name: String,
155
156 /// icon hash
157 pub icon: Option<String>,
158
159 /// splash hash
160 pub splash: Option<String>,
161
162 /// discovery splash hash; only present for guilds with the "DISCOVERABLE" feature
163 pub discovery_splash: Option<String>,
164
165 /// custom guild emojis
166 pub emojis: Vec<Emoji>,
167
168 /// enabled guild features
169 pub features: Vec<Feature>,
170
171 /// approximate number of members in this guild
172 pub approximate_member_count: u32,
173
174 /// approximate number of online members in this guild
175 pub approximate_presence_count: u32,
176
177 /// the description for the guild
178 pub description: Option<String>,
179
180 /// custom guild stickers
181 pub stickers: Vec<Sticker>,
182}
183
184#[repr(u8)]
185#[derive(Deserialize_repr, Serialize_repr, Debug)]
186pub enum SystemChannelFlags {
187 None,
188
189 /// Suppress member join notifications
190 SuppressJoinNotifications = 1 << 0,
191
192 /// Suppress server boost notifications
193 SuppressPremiumSubscriptions = 1 << 1,
194
195 /// Suppress server setup tips
196 SuppressGuildReminderNotifications = 1 << 2,
197
198 /// Hide member join sticker reply buttons
199 SuppressJoinNotificationReplies = 1 << 3,
200
201 /// Suppress role subscription purchase and renewal notifications
202 SuppressRoleSubscriptionPurchaseNotifications = 1 << 4,
203
204 /// Hide role subscription sticker reply buttons
205 SuppressRoleSubscriptionPurchaseNotificationReplies = 1 << 5,
206}
207
208#[repr(u8)]
209#[allow(non_camel_case_types)]
210#[derive(Deserialize_repr, Serialize_repr, Debug)]
211pub enum VerificationLevel {
212 /// unrestricted
213 NONE,
214
215 /// must have verified email on account
216 LOW,
217
218 /// must be registered on Discord for longer than 5 minutes
219 MEDIUM,
220
221 /// must be a member of the server for longer than 10 minutes
222 HIGH,
223
224 /// must have a verified phone number
225 VERY_HIGH,
226}
227
228#[derive(Deserialize, Serialize, Debug)]
229pub struct Guild {
230 /// guild id
231 pub id: Snowflake,
232
233 /// guild name (2-100 characters, excluding trailing and leading whitespace)
234 pub name: String,
235
236 /// icon hash
237 pub icon: Option<String>,
238
239 /// icon hash, returned when in the template object
240 pub icon_hash: Option<String>,
241
242 /// splash hash
243 pub splash: Option<String>,
244
245 /// discovery splash hash; only present for guilds with the "DISCOVERABLE" feature
246 pub discovery_splash: Option<String>,
247
248 /// true if the user is the owner of the guild
249 pub owner: Option<bool>,
250
251 /// id of owner
252 pub owner_id: Snowflake,
253
254 /// total permissions for the user in the guild (excludes overwrites and implicit permissions)
255 pub permissions: Option<String>,
256
257 /// voice region id for the guild (deprecated)
258 pub region: Option<String>,
259
260 /// id of afk channel
261 pub afk_channel_id: Option<Snowflake>,
262
263 /// afk timeout in seconds, can be set to: 60, 300, 900, 1800, 3600
264 pub afk_timeout: u16,
265
266 /// true if the server widget is enabled
267 pub widget_enabled: Option<bool>,
268
269 /// the channel id that the widget will generate an invite to, or null if set to no invite
270 pub widget_channel_id: Option<Snowflake>,
271
272 /// verification level required for the guild
273 pub verification_level: VerificationLevel,
274
275 /// default message notifications level
276 pub default_message_notifications: DefaultMessageNotifications,
277
278 /// explicit content filter level
279 pub explicit_content_filter: ExplicitContentFilter,
280
281 /// roles in the guild
282 pub roles: Vec<Role>,
283
284 /// custom guild emojis
285 pub emojis: Vec<Emoji>,
286
287 /// enabled guild features
288 pub features: Vec<Feature>,
289
290 /// required MFA level for the guild
291 pub mfa_level: MFALevel,
292
293 /// application id of the guild creator if it is bot-created
294 pub application_id: Option<Snowflake>,
295
296 /// the id of the channel where guild notices such as welcome messages and boost events are posted
297 pub system_channel_id: Option<Snowflake>,
298
299 /// system channel flags
300 pub system_channel_flags: SystemChannelFlags,
301
302 /// the id of the channel where Community guilds can display rules and/or guidelines
303 pub rules_channel_id: Option<Snowflake>,
304
305 /// the maximum number of presences for the guild (null is always returned, apart from the largest of guilds)
306 pub max_presences: Option<u32>,
307
308 /// the maximum number of members for the guild
309 pub max_members: Option<u32>,
310
311 /// the vanity url code for the guild
312 pub vanity_url_code: Option<String>,
313
314 /// the description of a guild
315 pub description: Option<String>,
316
317 /// banner hash
318 pub banner: Option<String>,
319
320 /// premium tier (Server Boost level)
321 pub premium_tier: PremiumTier,
322
323 /// the number of boosts this guild currently has
324 pub premium_subscription_count: Option<u16>,
325
326 /// the preferred locale of a Community guild; used in server discovery and notices from Discord, and sent in interactions; defaults to "en-US"
327 pub preferred_locale: String,
328
329 /// the id of the channel where admins and moderators of Community guilds receive notices from Discord
330 pub public_updates_channel_id: Option<Snowflake>,
331
332 /// the maximum amount of users in a video channel
333 pub max_video_channel_users: Option<u16>,
334
335 /// the maximum amount of users in a stage video channel
336 pub max_stage_video_channel_users: Option<u16>,
337
338 /// approximate number of members in this guild, returned from the GET /guilds/<id> and /users/@me/guilds endpoints when with_counts is true
339 pub approximate_member_count: Option<u32>,
340
341 /// approximate number of non-offline members in this guild, returned from the GET /guilds/<id> and /users/@me/guilds endpoints when with_counts is true
342 pub approximate_presence_count: Option<u32>,
343
344 /// the welcome screen of a Community guild, shown to new members, returned in an Invite's guild object
345 pub welcome_screen: Option<WelcomeScreen>,
346
347 /// guild NSFW level
348 pub nsfw_level: NSFWLevel,
349
350 /// custom guild stickers
351 pub stickers: Vec<Sticker>,
352
353 /// whether the guild has the boost progress bar enabled
354 pub premium_progress_bar_enabled: bool,
355
356 /// the id of the channel where admins and moderators of Community guilds receive safety alerts from Discord
357 pub safety_alerts_channel_id: Option<Snowflake>,
358}