public async Task GameLeaderboardCommand([Remainder] string game) { var _leaderboard = LeaderboardService.GetGameLeaderboard(game).ToList(); var _embed = new EmbedBuilder() .WithColor(Color.Blue) .WithThumbnailUrl(Context.Guild.IconUrl) .WithTitle($"Game leaderboards for: {Context.Guild.Name} on {game} ({_leaderboard.Count})"); // Build leaderboard StringBuilder _builder = new StringBuilder(); int _i = 0; foreach (var entry in _leaderboard) { if (_i == 10) { break; } var _user = Context.Guild.GetUser(entry.EntryStats.UserId); _builder.Append( $"\n**{_leaderboard.IndexOf(entry) + 1}.)** " + $"**{_user.Mention ?? (_user.Username + "#" + _user.Discriminator)}**" + $" - `{Math.Round(entry.Time.TotalHours, 1)}` hours."); _i++; } _embed.Description = _builder.ToString(); await ReplyAsync("", false, _embed.Build()); }
public async Task GameLeaderboardCommand() { var _leaderboard = LeaderboardService.GetGameLeaderboard(Context.Guild).OrderByDescending(s => s.Time).ToList(); var _userHighest = _leaderboard .Where(s => s.EntryStats.UserId == Context.User.Id) .OrderByDescending(s => s.Time) .FirstOrDefault(); var _embed = new EmbedBuilder() .WithColor(Color.Blue) .WithThumbnailUrl(Context.Guild.IconUrl) .WithTitle($"Game leaderboards for: {Context.Guild.Name} ({_leaderboard.Count})"); // Build leaderboard StringBuilder _builder = new StringBuilder(); int _i = 0; foreach (var entry in _leaderboard) { if (_i == 10) { break; } var _user = Context.Guild.GetUser(entry.EntryStats.UserId); _builder.Append( $"\n**{_leaderboard.IndexOf(entry) + 1}.)** " + $"**{_user.Mention ?? (_user.Username + "#" + _user.Discriminator)}**" + $" - *{entry.EntryStats.Game}*" + $" - `{Math.Round(entry.Time.TotalHours, 1)}` hours."); _i++; } _builder.Append($"\n\n**Your highest position**:" + $"\n**{_leaderboard.IndexOf(_userHighest) + 1}.)** " + $"*{_userHighest.EntryStats.Game}* " + $"- `{Math.Round(_userHighest.Time.TotalHours, 1)}` hours."); _embed.Description = _builder.ToString(); await ReplyAsync("", false, _embed.Build()); }