Esempio n. 1
0
        public async Task OsuTop(CommandContext ctx, string username = "")
        {
            await ctx.TriggerTypingAsync();

            if (username == "")
            {
                username = Utilities.ResolveName("osu", ctx.User);
            }

            var user = await osuApi.GetUserByNameAsync(username);

            var result = await osuApi.GetUserBestByUsernameAsync(username, limit : 50);

            var pages   = new List <Page>();
            var counter = 0;

            var eb      = new DiscordEmbedBuilder();
            var content = "";

            foreach (var map in result)
            {
                var mapInfo = await osuApi.GetBeatmapAsync(map.BeatmapId);

                content +=
                    $"**#{counter + 1} [{mapInfo.Title}](https://osu.ppy.sh/b/{map.BeatmapId})** [{mapInfo.Difficulty}] +{map.Mods} [{Math.Round(mapInfo.DifficultyRating, 2)}★]\n" +
                    $"» {DiscordEmoji.FromName(ctx.Client, $":{map.Rank}_Rank:")} » **{Math.Round(map.Pp, 2)}pp** » {Math.Round(map.Accuracy, 2)}%\n" +
                    $"» {map.TotalScore} » {map.MaxCombo}/{mapInfo.MaxCombo} » [{map.Count100}/{map.Count50}/{map.Miss}]\n" +
                    $"» Achieved on {map.Date:dd.MM.yy H:mm:ss}\n\n";

                if (++counter % 5 != 0)
                {
                    continue;
                }
                eb.WithAuthor($"Top osu! Standard Plays for {username}", $"https://osu.ppy.sh/users/{user.Userid}",
                              $"http://s.ppy.sh/a/{user.Userid}");
                eb.WithDescription(content);
                eb.WithColor(new DiscordColor(220, 152, 164));
                pages.Add(new Page(embed: eb));
                eb      = new DiscordEmbedBuilder();
                content = "";
            }

            await ctx.Client.GetInteractivity().SendPaginatedMessageAsync(ctx.Channel, ctx.User, pages);
        }