Skip to content

Commit

Permalink
Fix: send unavailable guilds in READY
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Reidel <[email protected]>
  • Loading branch information
Gelbpunkt committed Jun 24, 2024
1 parent 12d5d67 commit ec18995
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 22 additions & 22 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,33 @@ impl Guilds {
pub fn get_ready_payload(&self, mut ready: JsonObject, sequence: &mut usize) -> Payload {
*sequence += 1;

let unavailable_guilds = self
let guild_id_to_json = |guild_id: Id<GuildMarker>| {
#[cfg(feature = "simd-json")]
{
hashmap! {
String::from("id") => guild_id.to_string().into(),
String::from("unavailable") => true.into(),
}
.into()
}
#[cfg(not(feature = "simd-json"))]
{
serde_json::json!({
"id": guild.id().to_string(),
"unavailable": true
})
}
};

let guilds = self
.0
.iter()
.guilds()
.map(|guild| {
#[cfg(feature = "simd-json")]
{
hashmap! {
String::from("id") => guild.id().to_string().into(),
String::from("unavailable") => true.into(),
}
.into()
}
#[cfg(not(feature = "simd-json"))]
{
serde_json::json!({
"id": guild.id().to_string(),
"unavailable": true
})
}
})
.map(|guild| guild_id_to_json(guild.id()))
.chain(self.0.iter().unavailable_guilds().map(guild_id_to_json))
.collect();

ready.insert(
String::from("guilds"),
OwnedValue::Array(unavailable_guilds),
);
ready.insert(String::from("guilds"), OwnedValue::Array(guilds));

Payload {
d: Event::Ready(ready),
Expand Down

0 comments on commit ec18995

Please sign in to comment.