feat(event/mod): adding the database into ready event

This commit is contained in:
Raphael 2026-02-13 19:51:05 +01:00 committed by Raphaël
parent 5ffb334130
commit a26a21964d

View file

@ -1,4 +1,4 @@
pub mod bot;
include!("./mod_gen.rs");
use crate::commands::SlashCommand;
use serenity::all::*;
@ -8,7 +8,7 @@ use sqlx::PgPool;
pub trait BotEvent: Send + Sync {
fn event_type(&self) -> &'static str;
async fn on_ready(&self, _ctx: &Context, _ready: &Ready, _commands: &[Box<dyn SlashCommand>]) {}
async fn on_ready(&self, _ctx: &Context, _ready: &Ready, _commands: &[Box<dyn SlashCommand>], _db: &PgPool) {}
async fn on_interaction_create(
&self,
_ctx: &Context,
@ -43,7 +43,7 @@ pub struct Bot {
impl EventHandler for Bot {
async fn ready(&self, ctx: Context, ready: Ready) {
for event in self.events.iter().filter(|e| e.event_type() == "ready") {
event.on_ready(&ctx, &ready, &self.commands).await;
event.on_ready(&ctx, &ready, &self.commands, &self.database).await;
}
}