corrected guild counts for shards
This commit is contained in:
parent
775037fc6e
commit
2e9b06faf6
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1165,7 +1165,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reminder_rs"
|
name = "reminder_rs"
|
||||||
version = "1.0.0-rc.8"
|
version = "1.0.0-rc.9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "reminder_rs"
|
name = "reminder_rs"
|
||||||
version = "1.0.0-rc.8"
|
version = "1.0.0-rc.9"
|
||||||
authors = ["jellywx <judesouthworth@pm.me>"]
|
authors = ["jellywx <judesouthworth@pm.me>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
15
src/main.rs
15
src/main.rs
@ -87,15 +87,20 @@ DELETE FROM channels WHERE channel = ?
|
|||||||
async fn guild_create(&self, ctx: Context, guild: Guild, is_new: bool) {
|
async fn guild_create(&self, ctx: Context, guild: Guild, is_new: bool) {
|
||||||
if is_new {
|
if is_new {
|
||||||
if let Ok(token) = env::var("DISCORDBOTS_TOKEN") {
|
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 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();
|
let mut hm = HashMap::new();
|
||||||
hm.insert("server_count", guild_count);
|
hm.insert("server_count", guild_count);
|
||||||
hm.insert(
|
hm.insert("shard_id", current_shard_id);
|
||||||
"shard_id",
|
|
||||||
shard_id(guild.id.as_u64().to_owned(), shard_count),
|
|
||||||
);
|
|
||||||
hm.insert("shard_count", shard_count);
|
hm.insert("shard_count", shard_count);
|
||||||
|
|
||||||
let client = ctx
|
let client = ctx
|
||||||
|
Loading…
Reference in New Issue
Block a user