feat(events/bot): adding emoji field
This commit is contained in:
parent
1b052c92a0
commit
a104cbf453
1 changed files with 3 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
use serenity::all::*;
|
use serenity::all::*;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use crate::commands::SlashCommand;
|
use crate::commands::SlashCommand;
|
||||||
|
use crate::config::EmojiConfig;
|
||||||
use crate::events::{BotEvent, EventEntry};
|
use crate::events::{BotEvent, EventEntry};
|
||||||
|
|
||||||
pub struct InteractionHandler;
|
pub struct InteractionHandler;
|
||||||
|
|
@ -9,13 +10,13 @@ pub struct InteractionHandler;
|
||||||
impl BotEvent for InteractionHandler {
|
impl BotEvent for InteractionHandler {
|
||||||
fn event_type(&self) -> &'static str { "interaction_create" }
|
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 Interaction::Command(command) = interaction else { return };
|
||||||
|
|
||||||
let name: &str = command.data.name.as_str();
|
let name: &str = command.data.name.as_str();
|
||||||
match commands.iter().find(|cmd| cmd.name() == name) {
|
match commands.iter().find(|cmd| cmd.name() == name) {
|
||||||
Some(cmd) => {
|
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:?}");
|
eprintln!("❌ | Error on {name}: {why:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue