diff --git a/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs b/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs index 7bdfc496..6ac60f21 100644 --- a/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs +++ b/src/NadekoBot/Modules/Administration/Commands/SelfAssignedRolesCommand.cs @@ -150,11 +150,11 @@ namespace NadekoBot.Modules.Administration var guildUser = (IGuildUser)Context.User; GuildConfig conf; - IEnumerable roles; + SelfAssignedRole[] roles; using (var uow = DbHandler.UnitOfWork()) { conf = uow.GuildConfigs.For(Context.Guild.Id, set => set); - roles = uow.SelfAssignedRoles.GetFromGuild(Context.Guild.Id); + roles = uow.SelfAssignedRoles.GetFromGuild(Context.Guild.Id).ToArray(); } if (roles.FirstOrDefault(r=>r.RoleId == role.Id) == null) { @@ -167,15 +167,19 @@ namespace NadekoBot.Modules.Administration return; } + var roleIds = roles.Select(x => x.RoleId).ToArray(); if (conf.ExclusiveSelfAssignedRoles) { - var sameRoleId = guildUser.RoleIds.FirstOrDefault(r => roles.Select(sar => sar.RoleId).Contains(r)); + var sameRoleId = guildUser.RoleIds.FirstOrDefault(r => roleIds.Contains(r)); if (sameRoleId != default(ulong)) { var sameRole = Context.Guild.GetRole(sameRoleId); if (sameRole != null) + { await guildUser.RemoveRolesAsync(sameRole).ConfigureAwait(false); + await Task.Delay(500).ConfigureAwait(false); + } //await ReplyErrorLocalized("self_assign_already_excl", Format.Bold(sameRole?.Name)).ConfigureAwait(false); //return; }