diff options
author | Cara Salter <cara@devcara.com> | 2022-05-03 13:57:09 -0400 |
---|---|---|
committer | Cara Salter <cara@devcara.com> | 2022-05-03 13:57:09 -0400 |
commit | 5999e6a803a7b848acf054918fec9ee5024d5697 (patch) | |
tree | eae1f3986c41f7d7c1a956e4606a8120c6032e05 /src/handler.rs | |
parent | 8f4277c55a2079edf1c9a69383c353e1cb9ef55c (diff) | |
download | glitch-ng-5999e6a803a7b848acf054918fec9ee5024d5697.tar.gz glitch-ng-5999e6a803a7b848acf054918fec9ee5024d5697.zip |
filter: Initial message filter implementation
Also a custom error type, tracing_subscriber, and unsafe impls
Diffstat (limited to 'src/handler.rs')
-rw-r--r-- | src/handler.rs | 17 |
1 files changed, 15 insertions, 2 deletions
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?; + } + }, _ => (), } } |