.tesar will now really swap roles
This commit is contained in:
parent
1814936125
commit
42c394f53b
@ -150,11 +150,11 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var guildUser = (IGuildUser)Context.User;
|
var guildUser = (IGuildUser)Context.User;
|
||||||
|
|
||||||
GuildConfig conf;
|
GuildConfig conf;
|
||||||
IEnumerable<SelfAssignedRole> roles;
|
SelfAssignedRole[] roles;
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
conf = uow.GuildConfigs.For(Context.Guild.Id, set => set);
|
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)
|
if (roles.FirstOrDefault(r=>r.RoleId == role.Id) == null)
|
||||||
{
|
{
|
||||||
@ -167,15 +167,19 @@ namespace NadekoBot.Modules.Administration
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var roleIds = roles.Select(x => x.RoleId).ToArray();
|
||||||
if (conf.ExclusiveSelfAssignedRoles)
|
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))
|
if (sameRoleId != default(ulong))
|
||||||
{
|
{
|
||||||
var sameRole = Context.Guild.GetRole(sameRoleId);
|
var sameRole = Context.Guild.GetRole(sameRoleId);
|
||||||
if (sameRole != null)
|
if (sameRole != null)
|
||||||
|
{
|
||||||
await guildUser.RemoveRolesAsync(sameRole).ConfigureAwait(false);
|
await guildUser.RemoveRolesAsync(sameRole).ConfigureAwait(false);
|
||||||
|
await Task.Delay(500).ConfigureAwait(false);
|
||||||
|
}
|
||||||
//await ReplyErrorLocalized("self_assign_already_excl", Format.Bold(sameRole?.Name)).ConfigureAwait(false);
|
//await ReplyErrorLocalized("self_assign_already_excl", Format.Bold(sameRole?.Name)).ConfigureAwait(false);
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user