From 5999e6a803a7b848acf054918fec9ee5024d5697 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Tue, 3 May 2022 13:57:09 -0400 Subject: filter: Initial message filter implementation Also a custom error type, tracing_subscriber, and unsafe impls --- src/handler.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/handler.rs') diff --git a/src/handler.rs b/src/handler.rs index 7b4568f..a52b31a 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -1,6 +1,6 @@ use poise::serenity_prelude as serenity; -use crate::models::ReactionRole; +use crate::models::*; use crate::{Data, Error}; use tracing::info; @@ -72,7 +72,20 @@ pub async fn event_handler( } add_reaction.delete(&ctx.http).await?; - } + }, + poise::Event::Message { new_message } => { + let current_user = ctx.http.get_current_user().await?; + + if new_message.author.id.0 != current_user.id.0 { + // This message does *not* belong to the bot + println!("Message from not-bot"); + let filters = sqlx::query_as::<_, MessageFilter>( + "SELECT * FROM message_filter WHERE guild_id=$1") + .bind(new_message.guild_id.unwrap().0.to_string()) + .fetch_all(&pool) + .await?; + } + }, _ => (), } } -- cgit v1.2.3