From 6841c3969ae19128e569deb086d40d35437f9e8b Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 20 Dec 2024 23:44:49 +1300 Subject: [PATCH] fixed iam with exclusive roles (in some cases?) being broken --- .../SelfAssignableRoles/SelfAssignedRolesService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs index 7a100d4..20b332e 100644 --- a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs +++ b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesService.cs @@ -280,8 +280,12 @@ public sealed class SarAssignerService : IEService, IReadyExecutor if (item.Group.IsExclusive) { - var rolesToRemove = item.Group.Roles.Select(x => x.RoleId); - await item.User.RemoveRolesAsync(rolesToRemove); + var rolesToRemove = item.Group.Roles + .Where(x => item.User.RoleIds.Contains(x.RoleId)) + .Select(x => x.RoleId) + .ToArray(); + if (rolesToRemove.Length > 0) + await item.User.RemoveRolesAsync(rolesToRemove); } await item.User.AddRoleAsync(item.RoleId);