From 7f8d9de1a4a9716e86e32ad62bae89b2a910fa57 Mon Sep 17 00:00:00 2001 From: tec <tec@ucc.gu.uwa.edu.au> Date: Sun, 5 Apr 2020 15:20:24 +0800 Subject: [PATCH] Add role-react deletion technology :) --- src/reaction_roles.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/reaction_roles.rs b/src/reaction_roles.rs index fbc188d..4ba7a60 100644 --- a/src/reaction_roles.rs +++ b/src/reaction_roles.rs @@ -97,16 +97,25 @@ pub fn sync_all_role_reactions(ctx: &Context) { for react in &message.reactions { let react_as_string = get_string_from_react(&react.reaction_type); if mapping.contains_key(&react_as_string) { - continue + continue; } info!( " message #{}: Removing non-role react '{}'", i, react_as_string ); - for _illegal_react in - &message.reaction_users(ctx, react.reaction_type.clone(), Some(100), None) + for illegal_react_user in &message + .reaction_users(&ctx.http, react.reaction_type.clone(), Some(100), None) + .unwrap_or(vec![]) { - warn!(" need to implement react removal"); + message + .channel_id + .delete_reaction( + &ctx.http, + message.id, + Some(illegal_react_user.id), + react.reaction_type.clone(), + ) + .expect("Unable to delete react"); } } for (react, role) in *mapping { -- GitLab