Esempio n. 1
0
        public async Task malManga(params string[] mangaNameArr) // Stuck in loop ?
        {
            p.doAction(Context.User, Context.Guild.Id, Program.Module.AnimeManga);
            string mangaName = Program.addArgs(mangaNameArr);

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

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