style(events/bot): adding the tracing log on ready
This commit is contained in:
parent
c8344b4d9d
commit
c6fb232910
1 changed files with 13 additions and 12 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
use tracing::{info, warn};
|
||||||
use serenity::all::*;
|
use serenity::all::*;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use crate::commands::SlashCommand;
|
use crate::commands::SlashCommand;
|
||||||
|
|
@ -66,19 +67,19 @@ impl BotEvent for ReadyHandler {
|
||||||
fn event_type(&self) -> &'static str { "ready" }
|
fn event_type(&self) -> &'static str { "ready" }
|
||||||
|
|
||||||
async fn on_ready(&self, ctx: &Context, ready: &Ready, commands: &[Box<dyn SlashCommand>], db: &PgPool) {
|
async fn on_ready(&self, ctx: &Context, ready: &Ready, commands: &[Box<dyn SlashCommand>], db: &PgPool) {
|
||||||
println!("\nTTY is now running as: '{}'\n", ready.user.name);
|
info!("\nTTY is now running as: '{}'\n", ready.user.name);
|
||||||
|
|
||||||
println!("Starting commands registration:");
|
info!("Starting commands registration:");
|
||||||
let cmds: Vec<CreateCommand> = commands.iter().map(|c| c.register()).collect();
|
let cmds: Vec<CreateCommand> = commands.iter().map(|c| c.register()).collect();
|
||||||
Command::set_global_commands(&ctx.http, cmds)
|
Command::set_global_commands(&ctx.http, cmds)
|
||||||
.await
|
.await
|
||||||
.expect("❌ | Cannot register commands");
|
.expect("❌ | Cannot register commands");
|
||||||
|
|
||||||
println!("TTY now running with {} commands loaded\n", commands.len());
|
info!("TTY now running with {} commands loaded\n", commands.len());
|
||||||
|
|
||||||
bot_activity(ctx, &db).await;
|
bot_activity(ctx, &db).await;
|
||||||
|
|
||||||
println!("Synchronizing {} guilds\n", ready.guilds.len());
|
info!("Synchronizing {} guilds\n", ready.guilds.len());
|
||||||
|
|
||||||
let mut count: u128 = 0;
|
let mut count: u128 = 0;
|
||||||
|
|
||||||
|
|
@ -87,39 +88,39 @@ impl BotEvent for ReadyHandler {
|
||||||
let guild_id: String = guild.to_string();
|
let guild_id: String = guild.to_string();
|
||||||
|
|
||||||
if let Err(e) = guild::get_or_create(&db, &guild_id).await {
|
if let Err(e) = guild::get_or_create(&db, &guild_id).await {
|
||||||
eprintln!("\t❌ | Guild {} — {}", guild, e);
|
warn!("\t⚠️ | Guild {} — {}", guild, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let members: Vec<Member> = match fetch_all_members(ctx, guild).await {
|
let members: Vec<Member> = match fetch_all_members(ctx, guild).await {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("\t❌ | Guild {} — fetch members: {}", guild, e);
|
warn!("\t⚠️ | Guild {} — fetch members: {}", guild, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
println!("\t✅ | {} ({})", guild.name(ctx).expect("Undefined Name"), guild_id);
|
info!("\t✅ | {} ({})", guild.name(ctx).expect("Undefined Name"), guild_id);
|
||||||
for member in &members {
|
for member in &members {
|
||||||
if member.user.bot {
|
if member.user.bot {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let member_id: String = member.user.id.to_string();
|
let member_id: String = member.user.id.to_string();
|
||||||
if let Err(e) = user::get_or_create(&db, &member_id).await {
|
if let Err(e) = user::get_or_create(&db, &member_id).await {
|
||||||
eprintln!("\t\t❌ | User {} — {}", member_id, e);
|
warn!("\t\t⚠️ | User {} — {}", member_id, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Err(e) = guild_user::get_or_create(&db, &member_id, &guild_id).await {
|
if let Err(e) = guild_user::get_or_create(&db, &member_id, &guild_id).await {
|
||||||
eprintln!("\t\t❌ | GuildUser {}/{} — {}", guild, member_id, e);
|
warn!("\t\t⚠️ | GuildUser {}/{} — {}", guild, member_id, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
println!("\t\t✅ | {} ({})", member.user.name, member_id);
|
info!("\t\t✅ | {} ({})", member.user.name, member_id);
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
println!("\n");
|
info!("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("🚀 | Synchronization complete! {} users registered", count);
|
info!("🚀 | Synchronization complete! {} users registered", count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue