From 09b875da97396c4b15eb5bf4a900898f93b20365 Mon Sep 17 00:00:00 2001 From: Rafael Bradley Date: Tue, 12 Aug 2025 23:15:52 -0300 Subject: [PATCH] Add InteractionRunner to on_interaction_handlers --- src/framework/bot.rs | 6 +++--- src/framework/interactions/runner.rs | 20 ++++++++------------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/framework/bot.rs b/src/framework/bot.rs index 18e5b03..666c164 100644 --- a/src/framework/bot.rs +++ b/src/framework/bot.rs @@ -7,13 +7,13 @@ use twilight_http::Client; use crate::{ framework::{ - commands::{Command, runner::CommandRunner}, + commands::{runner::CommandRunner, Command}, events::traits::{ OnInteractionHandler, OnMessageDeleteHandler, OnMessageEditHandler, OnMessageHandler, OnReadyHandler, OnReconnectHandler, OnServerCreateHandler, OnServerDeleteHandler, OnServerUpdateHandler, }, - interactions::{components::Component, registry::ComponentRegistry}, + interactions::{components::Component, registry::ComponentRegistry, runner::InteractionRunner}, runtime::Runtime, }, utils::Bye, @@ -97,7 +97,7 @@ impl Bot { components: Vec::new(), on_ready_handlers: Vec::new(), on_reconnect_handlers: Vec::new(), - on_interaction_handlers: Vec::new(), + on_interaction_handlers: vec![Arc::new(InteractionRunner)], on_message_handlers: vec![Arc::new(CommandRunner)], on_message_edit_handlers: Vec::new(), on_message_delete_handlers: Vec::new(), diff --git a/src/framework/interactions/runner.rs b/src/framework/interactions/runner.rs index b27456e..79892bf 100644 --- a/src/framework/interactions/runner.rs +++ b/src/framework/interactions/runner.rs @@ -3,24 +3,20 @@ use std::sync::Arc; use async_trait::async_trait; use twilight_model::gateway::payload::incoming::InteractionCreate; -use crate::{ - framework::{ - events::traits::{EventResult, OnInteractionHandler}, - runtime::Runtime, - }, - state::State, +use crate::framework::{ + events::traits::{EventResult, OnInteractionHandler}, + runtime::Runtime, }; #[derive(Debug)] pub struct InteractionRunner; #[async_trait] -impl OnInteractionHandler for InteractionRunner { - async fn on_interaction( - &self, - event: &InteractionCreate, - rt: Arc>, - ) -> EventResult { +impl OnInteractionHandler for InteractionRunner +where + T: Send + Sync + 'static, +{ + async fn on_interaction(&self, event: &InteractionCreate, rt: Arc>) -> EventResult { Ok(rt.registry.execute(event, rt.clone()).await?) } }