feat(events/bot): adding emoji field

This commit is contained in:
Raphael 2026-02-15 23:42:24 +01:00
parent 1b052c92a0
commit a104cbf453
No known key found for this signature in database

View file

@ -1,6 +1,7 @@
use serenity::all::*;
use sqlx::PgPool;
use crate::commands::SlashCommand;
use crate::config::EmojiConfig;
use crate::events::{BotEvent, EventEntry};
pub struct InteractionHandler;
@ -9,13 +10,13 @@ pub struct InteractionHandler;
impl BotEvent for InteractionHandler {
fn event_type(&self) -> &'static str { "interaction_create" }
async fn on_interaction_create(&self, ctx: &Context, interaction: &Interaction, commands: &[Box<dyn SlashCommand>], db: &PgPool) {
async fn on_interaction_create(&self, ctx: &Context, interaction: &Interaction, commands: &[Box<dyn SlashCommand>], db: &PgPool, emoji: &EmojiConfig) {
let Interaction::Command(command) = interaction else { return };
let name: &str = command.data.name.as_str();
match commands.iter().find(|cmd| cmd.name() == name) {
Some(cmd) => {
if let Err(why) = cmd.run(ctx, command, db).await {
if let Err(why) = cmd.run(ctx, command, db, emoji).await {
eprintln!("❌ | Error on {name}: {why:?}");
}
}