Exemplo n.º 1
0
        public async Task Osu(CommandContext ctx, string username = "")
        {
            if (username == "")
            {
                if (Users.UserList.All(x => x.Id != ctx.User.Id))
                {
                    throw new Exception(
                              "I don't have an osu username linked to your discord account. Set it using `osu set [Name]`.");
                }

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

            var user = osuApi.GetUserByName(username);

            if (user == null)
            {
                throw new Exception($"No user by the name `{username}` was found!");
            }

            var eb = new DiscordEmbedBuilder()
                     .WithColor(new DiscordColor(220, 152, 164))
                     .WithAuthor($"{user.Username}'s osu! profile:", $"https://osu.ppy.sh/users/{user.Userid}")
                     .WithThumbnailUrl($"http://s.ppy.sh/a/{user.Userid}")
                     .WithDescription($"**Rank** » #{user.GlobalRank} ({user.Country}: #{user.RegionalRank})\n" +
                                      $"**PP** » {Math.Round(user.Pp)}\n" +
                                      $"**Accuracy** » {Math.Round(user.Accuracy, 2)}%\n" +
                                      $"**Playcount** » {user.PlayCount}\n");
            await ctx.RespondAsync(embed : eb.Build());
        }