Finish refactoring

This commit is contained in:
2025-08-10 21:15:53 -03:00
parent f123282699
commit a004fe2308
50 changed files with 2639 additions and 587 deletions
+1
View File
@@ -0,0 +1 @@
pub mod traits;
+83
View File
@@ -0,0 +1,83 @@
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;
}