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

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

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