Exemplo n.º 1
0
        public async Task Manga([Remainder] string input)
        {
            List <MangaDataModel> results;

            if (input == null)
            {
                results = await Weeb.GetMangaTrending();

                string msg = "";
                int    cnt = 1;
                foreach (var item in results)
                {
                    msg = msg + cnt + ". " + item.Attributes.Titles.EnJp + "\n";
                    cnt++;
                }
                await ReplyAsync("", false, Embed.GetEmbed($"**Currently Trending**", msg));
            }
            else
            {
                input   = input.Replace(' ', '-');
                results = await Weeb.GetManga(input);

                string msg = "*Please reply with the following int:*\n";
                int    cnt = 1;
                foreach (var item in results)
                {
                    msg = msg + "`" + cnt + ". " + item.Attributes.Titles.EnJp + "`\n";
                    cnt++;
                }
                int num = 0;

                await ReplyAndDeleteAsync("", false, Embed.GetEmbed($"**Please select a result**", msg), TimeSpan.FromMinutes(1));

                try
                {
                    var response = await NextMessageAsync(true, true, TimeSpan.FromMinutes(1));

                    num = int.Parse(response.Content) - 1;
                }
                catch
                {
                    await ReplyAndDeleteAsync("", false, Embed.GetEmbed($"**Oops something went wrong**", "You didnt reply before timeout or inputed an invalid number"));

                    return;
                }

                var tmp1    = results[num];
                var tmp     = tmp1.Attributes;
                int counter = 0;
                foreach (var item in Embed.GetEmbeds($"**{tmp.Titles.EnJp}**", Regex.Replace(Regex.Replace($"Synonyms: {string.Join(", ", tmp.AbbreviatedTitles ?? Enumerable.Empty<string>())}\nScore: {tmp.AverageRating}\nAge: {tmp.AgeRating}\nStatus: {tmp.Status}\nType: {tmp.MangaType}\nChapters: {tmp.ChapterCount.ToString() ?? "Unknown" }\nVolumes: {tmp.VolumeCount.ToString() ?? "Unknown"}\nRuntime: {tmp.StartDate} - {tmp.EndDate}\n{tmp.Synopsis}", @"<[^>]+>|&nbsp;", "").Trim(), @"\s{2,}", " "), tmp.PosterImage.Original ?? null))
                {
                    if (counter == 0)
                    {
                        await ReplyAsync($"https://kitsu.io/manga/{tmp1.Id ?? "error"}", false, item);
                    }
                    else
                    {
                        await ReplyAsync($"", false, item);
                    }
                }
            }
        }