35 lines
819 B
Rust
35 lines
819 B
Rust
use super::{utils::BotData, Error, Result};
|
|
|
|
use poise::{
|
|
serenity_prelude::{self as serenity},
|
|
Event,
|
|
};
|
|
use tracing::info;
|
|
|
|
mod everyone;
|
|
use everyone::handle_everyone_mention;
|
|
|
|
/// Function handling events the bot can see.
|
|
///
|
|
/// # Errors
|
|
///
|
|
/// This function will return an error if one of the functions error
|
|
/// themselves.
|
|
pub async fn event_handler(
|
|
ctx: &serenity::Context,
|
|
event: &Event<'_>,
|
|
_framework: poise::FrameworkContext<'_, BotData, Error>,
|
|
data: &BotData,
|
|
) -> Result {
|
|
match event {
|
|
Event::Ready { data_about_bot } => {
|
|
info!("Logged in as {}", data_about_bot.user.name);
|
|
}
|
|
Event::Message { new_message } => {
|
|
handle_everyone_mention(ctx, &data.database, new_message).await?;
|
|
}
|
|
_ => {}
|
|
}
|
|
Ok(())
|
|
}
|