public override async Task RewardAsync(CachedMember member) { foreach (var id in AddedRoleIds) { await member.GrantRoleAsync(id); } foreach (var id in RemovedRoleIds) { await member.RevokeRoleAsync(id); } }
public async ValueTask <AdminCommandResult> RevokeRoleAsync(CachedMember target, [RequireHierarchy] CachedRole role) { if (target.Roles.Keys.All(x => x != role.Id)) { return(CommandErrorLocalized("role_remove_role_exists", args: Markdown.Bold(target.Tag.Sanitize()))); } await target.RevokeRoleAsync(role.Id); return(CommandSuccessLocalized("role_remove_success", args: new object[] { Markdown.Bold(target.Tag.Sanitize()), role.Format() })); }
public async Task UpdateKingQueenAsync() { try { LogService.LogInformation("Update has been requested", LogSource.RoleService); var data = Services.GetRequiredService <DataService>(); var guild = Client.GetGuild(759143648339558412); var KingR = guild.GetRole(KingId); var QueenR = guild.GetRole(QueenId); var tmpking = data.ImposterKings.OrderByDescending(x => x.count).FirstOrDefault(); var tmpqueen = data.ImposterQueens.OrderByDescending(x => x.count).FirstOrDefault(); if (CurrentKing?.Id != tmpking.id) { LogService.LogInformation($"{CurrentKing} has been outranked.=> decrowning", LogSource.RoleService, guild.Id); if (CurrentKing != null) { await CurrentKing.RevokeRoleAsync(KingId); } CurrentKing = guild.GetMember(tmpking.id); await CurrentKing.GrantRoleAsync(KingId); LogService.LogInformation($"{CurrentKing} has crowned king", LogSource.RoleService, guild.Id); } if (CurrentQueen?.Id != tmpqueen.id) { LogService.LogInformation($"{CurrentQueen} has been outranked.=> decrowning", LogSource.RoleService, guild.Id); if (CurrentQueen != null) { await CurrentQueen.RevokeRoleAsync(QueenId); } CurrentQueen = guild.GetMember(tmpqueen.id); await CurrentQueen.GrantRoleAsync(QueenId); LogService.LogInformation($"{CurrentQueen} has crowned queen", LogSource.RoleService, guild.Id); } } catch (Exception e) { LogService.LogError($"uh oh shit broke", LogSource.RoleService, 0, e); } }