Ejemplo n.º 1
0
        public async Task mal(params string[] animeNameArr)
        {
            p.doAction(Context.User, Context.Guild.Id, Program.Module.AnimeManga);
            string animeName = Program.addArgs(animeNameArr);

            if (animeName.Length == 0)
            {
                await ReplyAsync(Sentences.animeHelp(Context.Guild.Id));

                return;
            }
            try
            {
                string result = p.malClient.DownloadString("https://myanimelist.net/api/anime/search.xml?q=" + animeName.Replace(" ", "%20"));
                if (!result.Contains("<entry>"))
                {
                    await ReplyAsync(Sentences.animeNotFound(Context.Guild.Id));
                }
                else
                {
                    EmbedBuilder b = parseContent(result, animeName, (Context.Channel as ITextChannel).IsNsfw);
                    await ReplyAsync("", false, b.Build());
                }
            }
            catch (WebException ex)
            {
                HttpWebResponse code = ex.Response as HttpWebResponse;
                if (code != null)
                {
                    if (code.StatusCode == HttpStatusCode.Forbidden)
                    {
                        await ReplyAsync(Sentences.tooManyRequests(Context.Guild.Id, "MyAnimeList"));
                    }
                }
                else
                {
                    await ReplyAsync("An unexpected error occured: " + ex.Message);
                }
            }
        }