2024-10-21 02:36:18 -04:00
|
|
|
mod ready;
|
|
|
|
mod shards;
|
|
|
|
|
2024-11-27 05:50:28 -05:00
|
|
|
use poise::serenity_prelude::FullEvent;
|
2024-10-21 02:36:18 -04:00
|
|
|
use rustbot_lib::{
|
2024-11-27 05:50:28 -05:00
|
|
|
RustbotFwCtx,
|
|
|
|
RustbotResult
|
2024-10-21 02:36:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
pub const RUSTBOT_EVENT: &str = "RustbotEvent";
|
|
|
|
|
|
|
|
struct EventProcessor<'a> {
|
2024-11-27 05:50:28 -05:00
|
|
|
framework: RustbotFwCtx<'a>
|
2024-10-21 02:36:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn processor(
|
2024-11-27 05:50:28 -05:00
|
|
|
framework: RustbotFwCtx<'_>,
|
2024-10-21 02:36:18 -04:00
|
|
|
event: &FullEvent
|
2024-11-27 05:50:28 -05:00
|
|
|
) -> RustbotResult<()> {
|
2024-10-21 02:36:18 -04:00
|
|
|
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(())
|
|
|
|
}
|