adiscord_types/gateway/guild.rs
1use super::presence;
2use crate::{api::{
3 channel::Channel,
4 emoji::Emoji,
5 feature::Feature,
6 guild::{
7 self, DefaultMessageNotifications, ExplicitContentFilter, MFALevel, NSFWLevel, PremiumTier,
8 SystemChannelFlags, VerificationLevel, WelcomeScreen,
9 },
10 role::Role,
11 stage::{PrivacyLevel, StageInstance},
12 sticker::Sticker,
13 user::User,
14 voice::VoiceState,
15}, Snowflake};
16use serde::Deserialize;
17use serde_repr::Deserialize_repr;
18
19#[derive(Deserialize, Debug)]
20pub struct Unavailable {
21 /// guild id
22 pub id: Snowflake,
23
24 /// unavailable or not
25 pub unavailable: Option<bool>,
26}
27
28#[repr(u8)]
29#[allow(non_camel_case_types)]
30#[derive(Deserialize_repr, Debug)]
31pub enum EventStatus {
32 SCHEDULED = 1,
33 ACTIVE,
34 COMPLETED,
35 CANCELED,
36}
37
38#[repr(u8)]
39#[allow(non_camel_case_types)]
40#[derive(Deserialize_repr, Debug)]
41pub enum EventEntityTypes {
42 STAGE_INSTANCE = 1,
43 VOICE,
44 EXTERNAL,
45}
46
47#[derive(Deserialize, Debug)]
48pub struct EventEntityMetadata {
49 /// location of the event (1-100 characters)
50 pub location: Option<String>,
51}
52
53#[derive(Deserialize, Debug)]
54pub struct Scheduled {
55 /// the id of the scheduled event
56 pub id: Snowflake,
57
58 /// the guild id which the scheduled event belongs to
59 pub guild_id: Snowflake,
60
61 /// the channel id in which the scheduled event will be hosted, or null if scheduled entity type is EXTERNAL
62 pub channel_id: Option<Snowflake>,
63
64 /// the id of the user that created the scheduled event *
65 pub creator_id: Option<Snowflake>,
66
67 /// the name of the scheduled event (1-100 characters)
68 pub name: String,
69
70 /// the description of the scheduled event (1-1000 characters)
71 pub description: Option<String>,
72
73 /// the time the scheduled event will start
74 pub scheduled_start_time: String,
75
76 /// the time the scheduled event will end, required if entity_type is EXTERNAL
77 pub scheduled_end_time: Option<String>,
78
79 /// the privacy level of the scheduled event
80 pub privacy_level: PrivacyLevel,
81
82 /// the status of the scheduled event
83 pub status: EventStatus,
84
85 /// the type of the scheduled event
86 pub entity_type: EventEntityTypes,
87
88 /// the id of an entity associated with a guild scheduled event
89 pub entity_id: Option<Snowflake>,
90
91 /// additional metadata for the guild scheduled event
92 pub entity_metadata: Option<EventEntityMetadata>,
93
94 /// the user that created the scheduled event
95 pub creator: Option<User>,
96
97 /// the number of users subscribed to the scheduled event
98 pub user_count: Option<u16>,
99
100 /// the cover image hash of the scheduled event
101 pub image: Option<String>,
102}
103
104#[derive(Deserialize, Debug)]
105pub struct Create {
106 /// guild id
107 pub id: Snowflake,
108
109 /// GUILD AVAILABLE:
110 /// true if this guild is unavailable due to an outage
111 ///
112 /// GUILD UNVAILABLE:
113 /// unavailable or not
114 pub unavailable: Option<bool>,
115
116 // GUILD SECTION
117 /// guild name (2-100 characters, excluding trailing and leading whitespace)
118 pub name: Option<String>,
119
120 /// icon hash
121 pub icon: Option<String>,
122
123 /// icon hash, returned when in the template object
124 pub icon_hash: Option<String>,
125
126 /// splash hash
127 pub splash: Option<String>,
128
129 /// discovery splash hash; only present for guilds with the "DISCOVERABLE" feature
130 pub discovery_splash: Option<String>,
131
132 /// true if the user is the owner of the guild
133 pub owner: Option<bool>,
134
135 /// id of owner
136 pub owner_id: Option<Snowflake>,
137
138 /// total permissions for the user in the guild (excludes overwrites)
139 pub permissions: Option<String>,
140
141 /// voice region id for the guild (deprecated)
142 pub region: Option<String>,
143
144 /// id of afk channel
145 pub afk_channel_id: Option<Snowflake>,
146
147 /// afk timeout in seconds, can be set to: 60, 300, 900, 1800, 3600
148 pub afk_timeout: Option<u16>,
149
150 /// true if the server widget is enabled
151 pub widget_enabled: Option<bool>,
152
153 /// the channel id that the widget will generate an invite to, or null if set to no invite
154 pub widget_channel_id: Option<Snowflake>,
155
156 /// verification level required for the guild
157 pub verification_level: Option<VerificationLevel>,
158
159 /// default message notifications level
160 pub default_message_notifications: Option<DefaultMessageNotifications>,
161
162 /// explicit content filter level
163 pub explicit_content_filter: Option<ExplicitContentFilter>,
164
165 /// roles in the guild
166 pub roles: Option<Vec<Role>>,
167
168 /// custom guild emojis
169 pub emojis: Vec<Emoji>,
170
171 /// enabled guild features
172 pub features: Option<Vec<Feature>>,
173
174 /// required MFA level for the guild
175 pub mfa_level: Option<MFALevel>,
176
177 /// application id of the guild creator if it is bot-created
178 pub application_id: Option<Snowflake>,
179
180 /// the id of the channel where guild notices such as welcome messages and boost events are posted
181 pub system_channel_id: Option<Snowflake>,
182
183 /// system channel flags
184 pub system_channel_flags: Option<SystemChannelFlags>,
185
186 /// the id of the channel where Community guilds can display rules and/or guidelines
187 pub rules_channel_id: Option<Snowflake>,
188
189 /// the maximum number of presences for the guild (null is always returned, apart from the largest of guilds)
190 pub max_presences: Option<u32>,
191
192 /// the maximum number of members for the guild
193 pub max_members: Option<u32>,
194
195 /// the vanity url code for the guild
196 pub vanity_url_code: Option<String>,
197
198 /// the description of a guild
199 pub description: Option<String>,
200
201 /// banner hash
202 pub banner: Option<String>,
203
204 /// premium tier (Server Boost level)
205 pub premium_tier: Option<PremiumTier>,
206
207 /// the number of boosts this guild currently has
208 pub premium_subscription_count: Option<u16>,
209
210 /// the preferred locale of a Community guild; used in server discovery and notices from Discord, and sent in interactions; defaults to "en-US"
211 pub preferred_locale: Option<String>,
212
213 /// the id of the channel where admins and moderators of Community guilds receive notices from Discord
214 pub public_updates_channel_id: Option<Snowflake>,
215
216 /// the maximum amount of users in a video channel
217 pub max_video_channel_users: Option<u16>,
218
219 /// the maximum amount of users in a stage video channel
220 pub max_stage_video_channel_users: Option<u16>,
221
222 /// approximate number of members in this guild, returned from the GET /guilds/<id> and /users/@me/guilds endpoints when with_counts is true
223 pub approximate_member_count: Option<u32>,
224
225 /// 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
226 pub approximate_presence_count: Option<u32>,
227
228 /// the welcome screen of a Community guild, shown to new members, returned in an Invite's guild object
229 pub welcome_screen: Option<WelcomeScreen>,
230
231 /// guild NSFW level
232 pub nsfw_level: Option<NSFWLevel>,
233
234 /// custom guild stickers
235 pub stickers: Option<Vec<Sticker>>,
236
237 /// whether the guild has the boost progress bar enabled
238 pub premium_progress_bar_enabled: Option<bool>,
239
240 /// the id of the channel where admins and moderators of Community guilds receive safety alerts from Discord
241 pub safety_alerts_channel_id: Option<Snowflake>,
242
243 /// When this guild was joined at
244 pub joined_at: String,
245
246 /// true if this is considered a large guild
247 pub large: bool,
248
249 /// Total number of members in this guild
250 pub member_count: u32,
251
252 /// States of members currently in voice channels; lacks the guild_id key
253 pub voice_states: Vec<VoiceState>,
254
255 /// Users in the guild
256 pub members: Vec<guild::Member>,
257
258 /// Channels in the guild
259 pub channels: Vec<Channel>,
260
261 /// All active threads in the guild that current user has permission to view
262 pub threads: Vec<Channel>,
263
264 /// Presences of the members in the guild, will only include non-offline members if the size is greater than large threshold
265 pub presences: Vec<presence::Update>,
266
267 /// Stage instances in the guild
268 pub stage_instances: Vec<StageInstance>,
269
270 /// Scheduled events in the guild
271 pub guild_scheduled_events: Vec<Scheduled>,
272}
273
274#[derive(Deserialize, Debug)]
275pub struct BanAdd {
276 /// ID of the guild
277 pub guild_id: Snowflake,
278
279 /// User who was banned
280 pub user: User,
281}
282
283#[derive(Deserialize, Debug)]
284pub struct BanRemove {
285 /// ID of the guild
286 pub guild_id: Snowflake,
287
288 /// User who was banned
289 pub user: User,
290}