public async Task Rank(IGuildUser userToView = null) { userToView = userToView ?? Context.User as IGuildUser; List <User> users = (await UserRepository.AllAsync(Context.Guild.Id)).OrderByDescending(x => x.Cash).ToList(); IRole rank = null; rank = await RankHandler.FetchRank(Context); var builder = new EmbedBuilder() { Title = $"Ranking of {userToView}", Color = new Color(0x00AE86), Description = $"Balance: {(await UserRepository.FetchUserAsync(Context)).Cash.ToString("C", Config.CI)}\n" + $"Position: #{users.FindIndex(x => x.UserId == userToView.Id) + 1}\n" }; if (rank != null) { builder.Description += $"Rank: {rank.Mention}"; } await ReplyAsync("", embed : builder); }
public async Task Rank([Remainder] IGuildUser userToView = null) { userToView = userToView ?? Context.User as IGuildUser; var users = DEABot.Users.Find(y => y.GuildId == Context.Guild.Id).ToList(); var sorted = users.OrderByDescending(x => x.Cash).ToList(); IRole rank = null; rank = RankHandler.FetchRank(Context); var builder = new EmbedBuilder() { Title = $"Ranking of {userToView}", Color = new Color(0x00AE86), Description = $"Balance: {UserRepository.FetchUser(userToView.Id, userToView.GuildId).Cash.ToString("C", Config.CI)}\n" + $"Position: #{sorted.FindIndex(x => x.UserId == userToView.Id) + 1}\n" }; if (rank != null) { builder.Description += $"Rank: {rank.Mention}"; } await ReplyAsync("", embed : builder); }