posting guild counts separately for shards. format default_prefix into info message
This commit is contained in:
		
							
								
								
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@@ -1165,7 +1165,7 @@ dependencies = [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "reminder_rs"
 | 
					name = "reminder_rs"
 | 
				
			||||||
version = "0.1.5"
 | 
					version = "0.1.6"
 | 
				
			||||||
dependencies = [
 | 
					dependencies = [
 | 
				
			||||||
 "Inflector",
 | 
					 "Inflector",
 | 
				
			||||||
 "async-trait",
 | 
					 "async-trait",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
[package]
 | 
					[package]
 | 
				
			||||||
name = "reminder_rs"
 | 
					name = "reminder_rs"
 | 
				
			||||||
version = "0.1.5"
 | 
					version = "0.1.6"
 | 
				
			||||||
authors = ["jellywx <judesouthworth@pm.me>"]
 | 
					authors = ["jellywx <judesouthworth@pm.me>"]
 | 
				
			||||||
edition = "2018"
 | 
					edition = "2018"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ use serenity::{client::Context, framework::standard::CommandResult, model::chann
 | 
				
			|||||||
use chrono::offset::Utc;
 | 
					use chrono::offset::Utc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::{
 | 
					use crate::{
 | 
				
			||||||
 | 
					    consts::DEFAULT_PREFIX,
 | 
				
			||||||
    models::{GuildData, UserData},
 | 
					    models::{GuildData, UserData},
 | 
				
			||||||
    SQLPool, THEME_COLOR,
 | 
					    SQLPool, THEME_COLOR,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -82,7 +83,8 @@ async fn info(ctx: &Context, msg: &Message, _args: String) -> CommandResult {
 | 
				
			|||||||
        .response(&pool, "info")
 | 
					        .response(&pool, "info")
 | 
				
			||||||
        .await
 | 
					        .await
 | 
				
			||||||
        .replacen("{user}", &ctx.cache.current_user().await.name, 1)
 | 
					        .replacen("{user}", &ctx.cache.current_user().await.name, 1)
 | 
				
			||||||
        .replacen("{prefix}", &guild_data.prefix, 1);
 | 
					        .replace("{default_prefix}", &*DEFAULT_PREFIX)
 | 
				
			||||||
 | 
					        .replace("{prefix}", &guild_data.prefix);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    msg.channel_id
 | 
					    msg.channel_id
 | 
				
			||||||
        .send_message(ctx, |m| {
 | 
					        .send_message(ctx, |m| {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										11
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/main.rs
									
									
									
									
									
								
							@@ -20,6 +20,7 @@ use serenity::{
 | 
				
			|||||||
        id::{GuildId, UserId},
 | 
					        id::{GuildId, UserId},
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    prelude::{Context, EventHandler, TypeMapKey},
 | 
					    prelude::{Context, EventHandler, TypeMapKey},
 | 
				
			||||||
 | 
					    utils::shard_id,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use sqlx::{
 | 
					use sqlx::{
 | 
				
			||||||
@@ -83,13 +84,19 @@ DELETE FROM channels WHERE channel = ?
 | 
				
			|||||||
        .unwrap();
 | 
					        .unwrap();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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;
 | 
					                let guild_count = ctx.cache.guild_count().await as u64;
 | 
				
			||||||
 | 
					                let shard_count = ctx.cache.shard_count().await;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                let mut hm = HashMap::new();
 | 
					                let mut hm = HashMap::new();
 | 
				
			||||||
                hm.insert("server_count", guild_count);
 | 
					                hm.insert("server_count", guild_count);
 | 
				
			||||||
 | 
					                hm.insert(
 | 
				
			||||||
 | 
					                    "shard_id",
 | 
				
			||||||
 | 
					                    shard_id(guild.id.as_u64().to_owned(), shard_count),
 | 
				
			||||||
 | 
					                );
 | 
				
			||||||
 | 
					                hm.insert("shard_count", shard_count);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                let client = ctx
 | 
					                let client = ctx
 | 
				
			||||||
                    .data
 | 
					                    .data
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user