Rustbot/events/src/events.rs

31 lines
695 B
Rust
Raw Normal View History

mod ready;
mod shards;
2024-11-27 05:50:28 -05:00
use poise::serenity_prelude::FullEvent;
use rustbot_lib::{
2024-11-27 05:50:28 -05:00
RustbotFwCtx,
RustbotResult
};
pub const RUSTBOT_EVENT: &str = "RustbotEvent";
struct EventProcessor<'a> {
2024-11-27 05:50:28 -05:00
framework: RustbotFwCtx<'a>
}
pub async fn processor(
2024-11-27 05:50:28 -05:00
framework: RustbotFwCtx<'_>,
event: &FullEvent
2024-11-27 05:50:28 -05:00
) -> RustbotResult<()> {
let processor = EventProcessor { framework };
match event {
FullEvent::Ready { data_about_bot } => processor.on_ready(data_about_bot).await?,
FullEvent::ShardsReady { total_shards } => processor.on_shards_ready(total_shards).await?,
FullEvent::ShardStageUpdate { event } => processor.on_shards_stageupdate(event).await?,
_ => {}
}
Ok(())
}