Exemple #1
0
        public async Task Recent(int count, [Remainder] string username)
        {
            if (string.IsNullOrEmpty(username))
            {
                await ReplyAsync("Username is null/empty, command usage is \"a.recent <count=1> [username]\"");

                return;
            }
            var user = await _api.GetUserByNameAsync(username);

            if (user == null)
            {
                return;
            }
            var recentScores = await _api.GetUserRecentAndBeatmapByUsernameAsync(username, limit : 1);

            if (recentScores.Count < 1)
            {
                return;
            }
            if (count == 1)
            {
                await ReplyAsync($"**Most recent play for {user.Username}:**", embed : CreateSinglePlayEmbed(user, recentScores[0].UserRecent, recentScores[0].Beatmap));
            }
            else
            {
                await ReplyAsync($"**Most recent plays for {user.Username}:**", embed : CreateMultiplePlayEmbed(user, recentScores));
            }
        }
Exemple #2
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);
        }