Пример #1
0
        public async Task XpGlobalLeaderboard(int page = 1)
        {
            if (--page < 0 || page > 100)
            {
                return;
            }
            var users = _service.GetUserXps(page);

            var embed = new EmbedBuilder()
                        .WithTitle(GetText("global_leaderboard"))
                        .WithOkColor();

            if (!users.Any())
            {
                embed.WithDescription("-");
            }
            else
            {
                for (int i = 0; i < users.Length; i++)
                {
                    var user = users[i];
                    embed.AddField(
                        $"#{(i + 1 + page * 9)} {(user.ToString())}",
                        $"{GetText("level_x", LevelStats.FromXp(users[i].TotalXp).Level)} - {users[i].TotalXp}xp");
                }
            }

            await Context.Channel.EmbedAsync(embed);
        }
Пример #2
0
        public Task XpLeaderboard(int page = 1)
        {
            if (--page < 0 || page > 100)
            {
                return(Task.CompletedTask);
            }

            return(Context.SendPaginatedConfirmAsync(page, (curPage) =>
            {
                var users = _service.GetUserXps(Context.Guild.Id, curPage);

                var embed = new EmbedBuilder()
                            .WithTitle(GetText("server_leaderboard"))
                            .WithOkColor();

                if (!users.Any())
                {
                    return embed.WithDescription("-");
                }
                else
                {
                    for (int i = 0; i < users.Length; i++)
                    {
                        var levelStats = LevelStats.FromXp(users[i].Xp + users[i].AwardedXp);
                        var user = ((SocketGuild)Context.Guild).GetUser(users[i].UserId);

                        var userXpData = users[i];

                        var awardStr = "";
                        if (userXpData.AwardedXp > 0)
                        {
                            awardStr = $"(+{userXpData.AwardedXp})";
                        }
                        else if (userXpData.AwardedXp < 0)
                        {
                            awardStr = $"({userXpData.AwardedXp.ToString()})";
                        }

                        embed.AddField(
                            $"#{(i + 1 + curPage * 9)} {(user?.ToString() ?? users[i].UserId.ToString())}",
                            $"{GetText("level_x", levelStats.Level)} - {levelStats.TotalXp}xp {awardStr}");
                    }
                    return embed;
                }
            }, 1000, 10, addPaginatedFooter: false));
        }