28 lines
742 B
Rust
28 lines
742 B
Rust
use std::sync::Arc;
|
|
|
|
use async_trait::async_trait;
|
|
use twilight_model::gateway::payload::incoming::InteractionCreate;
|
|
|
|
use crate::framework::commands::extras::ExtrasGetter;
|
|
use crate::framework::events::traits::{EventResult, OnInteractionHandler};
|
|
use crate::framework::runtime::Runtime;
|
|
|
|
#[derive(Debug)]
|
|
pub struct InteractionRunner;
|
|
|
|
#[async_trait]
|
|
impl<T, E> OnInteractionHandler<T, E> for InteractionRunner
|
|
where
|
|
T: Send + Sync + 'static,
|
|
E: Send + Sync + 'static,
|
|
{
|
|
async fn on_interaction(
|
|
&self,
|
|
event: &InteractionCreate,
|
|
rt: Arc<Runtime<T, E>>,
|
|
extras: Arc<dyn ExtrasGetter<T, Extras = E>>,
|
|
) -> EventResult {
|
|
Ok(rt.registry.execute(event, rt.clone(), extras).await?)
|
|
}
|
|
}
|