diff --git a/Cargo.lock b/Cargo.lock index 74f4734..51a34d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1338,7 +1338,7 @@ dependencies = [ [[package]] name = "soundfx-rs" -version = "1.0.1-rc.3" +version = "1.0.1-rc.4" dependencies = [ "dotenv", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index d684bed..0cc042e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "soundfx-rs" -version = "1.0.1-rc.3" +version = "1.0.1-rc.4" authors = ["jude-lafitteIII "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index 53d2b11..6ed0279 100644 --- a/src/main.rs +++ b/src/main.rs @@ -249,15 +249,20 @@ impl EventHandler for Handler { async fn guild_create(&self, ctx: Context, guild: Guild, is_new: bool) { if is_new { if let Ok(token) = env::var("DISCORDBOTS_TOKEN") { - let guild_count = ctx.cache.guild_count().await as u64; let shard_count = ctx.cache.shard_count().await; + let current_shard_id = shard_id(guild.id.as_u64().to_owned(), shard_count); + + let guild_count = ctx + .cache + .guilds() + .await + .iter() + .filter(|g| shard_id(g.as_u64().to_owned(), shard_count) == current_shard_id) + .count() as u64; let mut hm = HashMap::new(); hm.insert("server_count", guild_count); - hm.insert( - "shard_id", - shard_id(guild.id.as_u64().to_owned(), shard_count), - ); + hm.insert("shard_id", current_shard_id); hm.insert("shard_count", shard_count); let client = ctx