From 59accae1e5b6848592b0beaa6f0e6c481288d357 Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Wed, 17 Jan 2024 08:33:25 -0600 Subject: Don't try to re-add a role the user already has. --- src/handlers/x500_mapper.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/handlers/x500_mapper.rs b/src/handlers/x500_mapper.rs index 36ce386..1ec35f2 100644 --- a/src/handlers/x500_mapper.rs +++ b/src/handlers/x500_mapper.rs @@ -113,10 +113,12 @@ impl X500Mapper { if let Some(role) = self.config.students_role { log::info!("adding the role {} to {}", role, member.display_name()); - member - .add_role(&ctx.http, role) - .await - .context("failed to add student role")? + if !member.roles.contains(&role) { + member + .add_role(&ctx.http, role) + .await + .context("failed to add student role")? + } } Ok::<_, anyhow::Error>(()) -- cgit v1.2.3