84 lines
2.0 KiB
Rust
84 lines
2.0 KiB
Rust
use std::{error::Error, fmt::Debug, sync::Arc};
|
|
|
|
use async_trait::async_trait;
|
|
use twilight_model::gateway::payload::incoming::{
|
|
GuildCreate, GuildDelete, GuildUpdate, InteractionCreate, MessageCreate, MessageDelete,
|
|
MessageUpdate, Ready,
|
|
};
|
|
|
|
use crate::framework::runtime::Runtime;
|
|
|
|
pub type EventResult = Result<(), Box<dyn Error>>;
|
|
|
|
#[async_trait]
|
|
pub trait OnReadyHandler<T>: Send + Sync + Debug
|
|
where
|
|
T: Send + Sync,
|
|
{
|
|
async fn on_ready(&self, event: &Ready, rt: Arc<Runtime<T>>) -> EventResult;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait OnReconnectHandler<T>: Send + Sync + Debug
|
|
where
|
|
T: Send + Sync,
|
|
{
|
|
async fn on_reconnect(&self, rt: Arc<Runtime<T>>) -> EventResult;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait OnInteractionHandler<T>: Send + Sync + Debug
|
|
where
|
|
T: Send + Sync,
|
|
{
|
|
async fn on_interaction(&self, event: &InteractionCreate, rt: Arc<Runtime<T>>) -> EventResult;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait OnMessageHandler<T>: Send + Sync + Debug
|
|
where
|
|
T: Send + Sync,
|
|
{
|
|
async fn on_message(&self, event: &MessageCreate, rt: Arc<Runtime<T>>) -> EventResult;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait OnMessageEditHandler<T>: Send + Sync + Debug
|
|
where
|
|
T: Send + Sync,
|
|
{
|
|
async fn on_message_edit(&self, event: &MessageUpdate, rt: Arc<Runtime<T>>) -> EventResult;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait OnMessageDeleteHandler<T>: Send + Sync + Debug
|
|
where
|
|
T: Send + Sync,
|
|
{
|
|
async fn on_message_delete(&self, event: &MessageDelete, rt: Arc<Runtime<T>>) -> EventResult;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait OnServerCreateHandler<T>: Send + Sync + Debug
|
|
where
|
|
T: Send + Sync,
|
|
{
|
|
async fn on_server_create(&self, event: &GuildCreate, rt: Arc<Runtime<T>>) -> EventResult;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait OnServerUpdateHandler<T>: Send + Sync + Debug
|
|
where
|
|
T: Send + Sync,
|
|
{
|
|
async fn on_server_update(&self, event: &GuildUpdate, rt: Arc<Runtime<T>>) -> EventResult;
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait OnServerDeleteHandler<T>: Send + Sync + Debug
|
|
where
|
|
T: Send + Sync,
|
|
{
|
|
async fn on_server_delete(&self, event: &GuildDelete, rt: Arc<Runtime<T>>) -> EventResult;
|
|
}
|