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
use twilight_model::{
guild::{
DefaultMessageNotificationLevel, ExplicitContentFilter, Guild, GuildFeature, MfaLevel,
NSFWLevel, PartialGuild, Permissions, PremiumTier, SystemChannelFlags, VerificationLevel,
},
id::{
marker::{ApplicationMarker, ChannelMarker, GuildMarker, UserMarker},
Id,
},
util::{ImageHash, Timestamp},
};
#[derive(Clone, Debug)]
#[cfg_attr(feature = "tests", derive(PartialEq, Eq))]
pub struct CachedGuild {
pub afk_channel_id: Option<Id<ChannelMarker>>,
pub afk_timeout: u64,
pub application_id: Option<Id<ApplicationMarker>>,
pub banner: Option<ImageHash>,
pub default_message_notifications: DefaultMessageNotificationLevel,
pub description: Option<String>,
pub discovery_splash: Option<ImageHash>,
pub explicit_content_filter: ExplicitContentFilter,
pub features: Vec<GuildFeature>,
pub icon: Option<ImageHash>,
pub id: Id<GuildMarker>,
pub joined_at: Option<Timestamp>,
pub large: bool,
pub max_members: Option<u64>,
pub max_presences: Option<u64>,
pub max_video_channel_users: Option<u64>,
pub mfa_level: MfaLevel,
pub name: String,
pub nsfw_level: NSFWLevel,
pub owner_id: Id<UserMarker>,
pub owner: Option<bool>,
pub permissions: Option<Permissions>,
pub preferred_locale: String,
pub premium_progress_bar_enabled: bool,
pub premium_subscription_count: Option<u64>,
pub premium_tier: PremiumTier,
pub rules_channel_id: Option<Id<ChannelMarker>>,
pub splash: Option<ImageHash>,
pub system_channel_flags: SystemChannelFlags,
pub system_channel_id: Option<Id<ChannelMarker>>,
pub unavailable: bool,
pub vanity_url_code: Option<String>,
pub verification_level: VerificationLevel,
pub widget_channel_id: Option<Id<ChannelMarker>>,
pub widget_enabled: Option<bool>,
}
impl CachedGuild {
pub fn update(&mut self, guild: &PartialGuild) {
self.id = guild.id;
self.afk_channel_id = guild.afk_channel_id;
self.afk_timeout = guild.afk_timeout;
self.application_id = guild.application_id;
self.banner = guild.banner;
self.default_message_notifications = guild.default_message_notifications;
self.description.clone_from(&guild.description);
self.discovery_splash = guild.discovery_splash;
self.explicit_content_filter = guild.explicit_content_filter;
self.features.clone_from(&guild.features);
self.icon.clone_from(&guild.icon);
self.max_members = guild.max_members;
self.max_presences = guild.max_presences;
self.mfa_level = guild.mfa_level;
self.name.clone_from(&guild.name);
self.nsfw_level = guild.nsfw_level;
self.owner_id = guild.owner_id;
self.owner = guild.owner;
self.permissions = guild.permissions;
self.preferred_locale.clone_from(&guild.preferred_locale);
self.premium_progress_bar_enabled = guild.premium_progress_bar_enabled;
self.premium_subscription_count = guild.premium_subscription_count;
self.premium_tier = guild.premium_tier;
self.rules_channel_id = guild.rules_channel_id;
self.splash = guild.splash;
self.system_channel_flags = guild.system_channel_flags;
self.system_channel_id = guild.system_channel_id;
self.verification_level = guild.verification_level;
self.vanity_url_code.clone_from(&guild.vanity_url_code);
self.widget_channel_id = guild.widget_channel_id;
self.widget_enabled = guild.widget_enabled;
}
}
impl From<&Guild> for CachedGuild {
fn from(guild: &Guild) -> Self {
Self {
afk_channel_id: guild.afk_channel_id,
afk_timeout: guild.afk_timeout,
application_id: guild.application_id,
banner: guild.banner,
default_message_notifications: guild.default_message_notifications,
description: guild.description.clone(),
discovery_splash: guild.discovery_splash,
explicit_content_filter: guild.explicit_content_filter,
features: guild.features.clone(),
icon: guild.icon,
id: guild.id,
joined_at: guild.joined_at,
large: guild.large,
max_members: guild.max_members,
max_presences: guild.max_presences,
max_video_channel_users: guild.max_video_channel_users,
mfa_level: guild.mfa_level,
name: guild.name.clone(),
nsfw_level: guild.nsfw_level,
owner_id: guild.owner_id,
owner: guild.owner,
permissions: guild.permissions,
preferred_locale: guild.preferred_locale.clone(),
premium_progress_bar_enabled: guild.premium_progress_bar_enabled,
premium_subscription_count: guild.premium_subscription_count,
premium_tier: guild.premium_tier,
rules_channel_id: guild.rules_channel_id,
splash: guild.splash,
system_channel_flags: guild.system_channel_flags,
system_channel_id: guild.system_channel_id,
unavailable: guild.unavailable,
vanity_url_code: guild.vanity_url_code.clone(),
verification_level: guild.verification_level,
widget_channel_id: guild.widget_channel_id,
widget_enabled: guild.widget_enabled,
}
}
}