Skip to content

Commit ec18995

Browse files
committed
Fix: send unavailable guilds in READY
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
1 parent 12d5d67 commit ec18995

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cache.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,33 @@ impl Guilds {
5858
pub fn get_ready_payload(&self, mut ready: JsonObject, sequence: &mut usize) -> Payload {
5959
*sequence += 1;
6060

61-
let unavailable_guilds = self
61+
let guild_id_to_json = |guild_id: Id<GuildMarker>| {
62+
#[cfg(feature = "simd-json")]
63+
{
64+
hashmap! {
65+
String::from("id") => guild_id.to_string().into(),
66+
String::from("unavailable") => true.into(),
67+
}
68+
.into()
69+
}
70+
#[cfg(not(feature = "simd-json"))]
71+
{
72+
serde_json::json!({
73+
"id": guild.id().to_string(),
74+
"unavailable": true
75+
})
76+
}
77+
};
78+
79+
let guilds = self
6280
.0
6381
.iter()
6482
.guilds()
65-
.map(|guild| {
66-
#[cfg(feature = "simd-json")]
67-
{
68-
hashmap! {
69-
String::from("id") => guild.id().to_string().into(),
70-
String::from("unavailable") => true.into(),
71-
}
72-
.into()
73-
}
74-
#[cfg(not(feature = "simd-json"))]
75-
{
76-
serde_json::json!({
77-
"id": guild.id().to_string(),
78-
"unavailable": true
79-
})
80-
}
81-
})
83+
.map(|guild| guild_id_to_json(guild.id()))
84+
.chain(self.0.iter().unavailable_guilds().map(guild_id_to_json))
8285
.collect();
8386

84-
ready.insert(
85-
String::from("guilds"),
86-
OwnedValue::Array(unavailable_guilds),
87-
);
87+
ready.insert(String::from("guilds"), OwnedValue::Array(guilds));
8888

8989
Payload {
9090
d: Event::Ready(ready),

0 commit comments

Comments
 (0)