use crate::commands::{handle_interaction, set_commands, CommandsConfig}; use serenity::{ all::{Interaction, Ready}, async_trait, client::{Context, EventHandler}, }; use sqlx::SqlitePool; /// A handler that sets up the commands. pub struct Commands { pub config: CommandsConfig, pub db: SqlitePool, } #[async_trait] impl EventHandler for Commands { async fn ready(&self, ctx: Context, _data_about_bot: Ready) { if let Err(err) = set_commands(&ctx).await { log::error!("failed to set commands: {:?}", err) } } async fn interaction_create(&self, ctx: Context, interaction: Interaction) { if let Err(err) = handle_interaction(&ctx, &self.config, &self.db, &interaction).await { log::error!("failed to handle interaction: {:?}", err); log::error!("failed interaction was: {:?}", interaction); } } }