예제 #1
0
        public async Task GetRecommendations(CommandContext ctx, [RemainingText] string title = "")
        {
            var isShort = await IsTitleShort(title, ctx);

            if (isShort == true)
            {
                return;
            }

            IJikan jikan = new Jikan();
            var    anime = await GetAnimeFromSearch(title);

            var id = anime.MalId;

            //uses id to fetch info
            Recommendations recommendations = await jikan.GetAnimeRecommendations(id);

            var resultEmbed = new DiscordEmbedBuilder
            {
                Title = $"If you liked {anime.Title} you might also like:",
                Color = DiscordColor.Azure,
            };

            for (int i = 0; i <= 5; i++)
            {
                var recommendation = recommendations.RecommendationCollection.ElementAt(i);
                resultEmbed.AddField(recommendation.Title, recommendation.Url);
            }
            resultEmbed.WithFooter("source: MyAnimeList.net");
            resultEmbed.WithThumbnail(anime.ImageURL);

            await ctx.Channel.SendMessageAsync(embed : resultEmbed);
        }