.aar cleanup, will disable itself if not enough permissions or when role gets deleted.
This commit is contained in:
@ -31,29 +31,14 @@ namespace NadekoBot.Modules.Administration
|
||||
if (Context.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= role.Position)
|
||||
return;
|
||||
|
||||
using (var uow = _db.UnitOfWork)
|
||||
{
|
||||
var conf = uow.GuildConfigs.For(Context.Guild.Id, set => set);
|
||||
if (role == null)
|
||||
{
|
||||
conf.AutoAssignRoleId = 0;
|
||||
_service.AutoAssignedRoles.TryRemove(Context.Guild.Id, out _);
|
||||
}
|
||||
else
|
||||
{
|
||||
conf.AutoAssignRoleId = role.Id;
|
||||
_service.AutoAssignedRoles.AddOrUpdate(Context.Guild.Id, role.Id, (key, val) => role.Id);
|
||||
}
|
||||
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (role == null)
|
||||
{
|
||||
_service.DisableAar(Context.Guild.Id);
|
||||
await ReplyConfirmLocalized("aar_disabled").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
_service.EnableAar(Context.Guild.Id, role.Id);
|
||||
await ReplyConfirmLocalized("aar_enabled").ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user