aboutsummaryrefslogtreecommitdiff
path: root/src/handler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/handler.rs')
-rw-r--r--src/handler.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/handler.rs b/src/handler.rs
index ef8fc00..7b4568f 100644
--- a/src/handler.rs
+++ b/src/handler.rs
@@ -3,6 +3,12 @@ use poise::serenity_prelude as serenity;
use crate::models::ReactionRole;
use crate::{Data, Error};
+use tracing::info;
+
+/**
+ * Handles specific events, including ReactionAdd, which is needed for the reaction role handler to
+ * function properly
+ */
pub async fn event_handler(
ctx: &serenity::Context,
event: &poise::Event<'_>,
@@ -16,6 +22,7 @@ pub async fn event_handler(
if add_reaction.user_id.unwrap() == current_user.id {
return Ok(());
}
+ // This fetches the role and lets us query extra data including role ID
let rrole = sqlx::query_as!(
ReactionRole,
"SELECT * FROM reaction_roles WHERE message_id=$1 AND reaction=$2",
@@ -31,6 +38,7 @@ pub async fn event_handler(
add_reaction.user_id.unwrap().0,
)
.await?;
+ // Honestly, not really needed.
let member_roles = member.roles;
let role_id = serenity::RoleId(rrole.role_id.parse::<u64>()?);
if member_roles.contains(&role_id) {
@@ -60,7 +68,7 @@ pub async fn event_handler(
.await {
dm_chan.say(ctx, format!("Toggled the role!")).await?;
} else {
- println!("Could not DM user, but we did the role anyways");
+ info!("Could not DM user, but we did the role anyways");
}
add_reaction.delete(&ctx.http).await?;