From 3ec1b48a6838e52a0d83ae98ed196f66e67e149d Mon Sep 17 00:00:00 2001 From: Ivin Joel Abraham Date: Wed, 16 Oct 2024 00:24:06 +0530 Subject: [PATCH] add feature to give roles on adding reactions --- src/commands.rs | 2 +- src/main.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 2c58dbd..0d702b3 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -15,9 +15,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ +use crate::Context; use crate::Data; use crate::Error; -use crate::Context; #[poise::command(prefix_command)] async fn amdctl(ctx: Context<'_>) -> Result<(), Error> { diff --git a/src/main.rs b/src/main.rs index 1472e6a..28af8ed 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ struct Data { reaction_roles: HashMap, } -const ARCHIVE_MESSAGE_ID: u64 = 1295815208689733703; +const ARCHIVE_MESSAGE_ID: u64 = 1295821555586175083; const ARCHIVE_ROLE_ID: u64 = 1208457364274028574; #[shuttle_runtime::main] @@ -110,7 +110,9 @@ async fn event_handler( if let Ok(member) = guild_id.member(ctx, add_reaction.user_id.unwrap()).await { - let _ = member.add_role(&ctx.http, *role_id).await; + if let Err(e) = member.add_role(&ctx.http, *role_id).await { + eprintln!("Error: {:?}", e); + } } } } @@ -124,10 +126,11 @@ async fn event_handler( if &removed_reaction.emoji == expected_reaction { if let Some(guild_id) = removed_reaction.guild_id { if let Ok(member) = guild_id - .member(ctx, removed_reaction.user_id.unwrap()) - .await + .member(ctx, removed_reaction.user_id.unwrap()).await { - let _ = member.remove_role(&ctx.http, *role_id).await; + if let Err(e) = member.remove_role(&ctx.http, *role_id).await { + eprintln!("Error: {:?}", e); + } } } }