diff --git a/src/definitions.rs b/src/definitions.rs index e870948..4c6885e 100644 --- a/src/definitions.rs +++ b/src/definitions.rs @@ -1,10 +1,11 @@ -// Tokio async crap - -use poise::serenity_prelude as serenity; +const SLOP_SCOUNDREL_SERVER_ID: u64 = 752667089155915846; +const SLOP_SCOUNDREL_ROLE_ID: u64 = 1508961172223951078; #[allow(unused_imports)] use crate::settings::*; +use poise::serenity_prelude::{self as serenity, FullEvent, RoleId}; + // Data passed to every command (shared state) pub struct Data {} @@ -15,13 +16,31 @@ pub type Error = Box; pub type Context<'a> = poise::Context<'a, Data, Error>; pub async fn event_handler( - _ctx: &serenity::Context, - _event: &serenity::FullEvent, + ctx: &serenity::Context, + event: &serenity::FullEvent, _framework: poise::FrameworkContext<'_, Data, Error>, _data: &Data, ) -> Result<(), Error> { // Future event handling will go here // Data will contain the database connection - + match &event { + &FullEvent::Message { new_message } => { + if new_message.guild_id.unwrap() == SLOP_SCOUNDREL_SERVER_ID { + if new_message + .author + .has_role( + ctx.http.clone(), + new_message.guild_id.unwrap(), + RoleId::new(SLOP_SCOUNDREL_ROLE_ID), + ) + .await + .unwrap() && !new_message.attachments.is_empty() + { + new_message.channel_id.say(ctx.http.clone(), "kys").await?; + } + } + } + _ => {} + } Ok(()) } diff --git a/src/event_handlers.rs b/src/event_handlers.rs index 20565f5..8b13789 100644 --- a/src/event_handlers.rs +++ b/src/event_handlers.rs @@ -1,2 +1 @@ -#[allow(dead_code)] -const SLOP_SCOUNDREL_ROLE_ID: u64 = 1508961172223951078; +