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
use serde::Serialize;
use twilight_model::{
gateway::presence::{Activity, ClientStatus, Presence, Status},
id::{GuildId, UserId},
};
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct CachedPresence {
pub(crate) activities: Vec<Activity>,
pub(crate) client_status: ClientStatus,
pub(crate) guild_id: GuildId,
pub(crate) status: Status,
pub(crate) user_id: UserId,
}
impl CachedPresence {
pub fn activities(&self) -> &[Activity] {
&self.activities
}
pub const fn client_status(&self) -> &ClientStatus {
&self.client_status
}
pub const fn guild_id(&self) -> GuildId {
self.guild_id
}
pub const fn status(&self) -> Status {
self.status
}
pub const fn user_id(&self) -> UserId {
self.user_id
}
}
impl PartialEq<Presence> for CachedPresence {
fn eq(&self, other: &Presence) -> bool {
(
&self.activities,
&self.client_status,
self.guild_id,
self.status,
self.user_id,
) == (
&other.activities,
&other.client_status,
other.guild_id,
other.status,
other.user.id(),
)
}
}
impl From<Presence> for CachedPresence {
fn from(presence: Presence) -> Self {
Self {
activities: presence.activities,
client_status: presence.client_status,
guild_id: presence.guild_id,
status: presence.status,
user_id: presence.user.id(),
}
}
}