feat(events/bot): adding a interaction_create file

This commit is contained in:
Raphael 2026-02-12 16:19:37 +01:00
parent 94f2ac047b
commit a4576acdc2
No known key found for this signature in database

View file

@ -0,0 +1,24 @@
use serenity::all::*;
use crate::commands::SlashCommand;
pub async fn handle(
ctx: &Context,
interaction: &Interaction,
commands: &[Box<dyn SlashCommand>],
) {
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).await {
eprintln!("❌ | Error on {name}: {why:?}");
}
}
None => eprintln!("⚠️ | Unable to fetch: /{name}"),
}
}