Beispiel #1
0
        /// <summary>
        /// Adds manga to specific user's list
        /// </summary>
        /// <param name="searchEntry">The search entry you found.</param>
        /// <param name="status">The status of the manga Reading, Completed, Onhold, Dropped...</param>
        /// <returns>A string represnting the state of adding "Created" or detailed error message.</returns>
        public string AddManga(MangaSearchEntry searchEntry, MangaListStatus status)
        {
            m_api.CheckAuth();
            MangaEntry addedManga = new MangaEntry()
            {
                Status = status,
            };

            return(m_api.PostSerializedObject(addedManga, string.Format(MAL.url_addManga, searchEntry.Id)));
        }
Beispiel #2
0
        /// <summary>
        /// Adds manga to specific user's list
        /// </summary>
        /// <param name="searchEntry">The search entry you found.</param>
        /// <param name="status">The status of the manga Reading, Completed, Onhold, Dropped...</param>
        /// <returns>A string represnting the state of adding "Created" or detailed error message.</returns>
        public async Task <string> AddMangaAsync(MangaSearchEntry searchEntry, MangaListStatus status)
        {
            m_api.CheckAuthAsync();

            MangaEntry addedManga = new MangaEntry()
            {
                Status = status,
            };

            return(await m_api.PostSerializedObjectAsync(addedManga, string.Format(MAL.url_addManga, searchEntry.Id)));
        }
Beispiel #3
0
        public async Task MangaSearch(CommandContext ctx, [RemainingText] string title)
        {
            var isShort = await IsTitleShort(title, ctx);

            if (isShort == true)
            {
                return;
            }

            // Initialize JikanWrapper
            IJikan jikan = new Jikan(true);

            var interactivity = ctx.Client.GetInteractivity();

            MangaSearchResult animeSearchResult = await jikan.SearchManga(title); //gets the anime based on title argument

            var firstFiveResults = animeSearchResult.Results.Take(5);

            string responseContent = $"Please respond with the **number** of your desired title:";
            var    forCount        = 0;

            foreach (var item in firstFiveResults)
            {
                forCount++;
                responseContent = responseContent + $"\n **{forCount}**: {item.Title}";
            }
            var response = await ctx.Channel.SendMessageAsync(responseContent);

            var index = await interactivity.WaitForMessageAsync(x => x.Channel == ctx.Channel && x.Author.Id == ctx.Member.Id);

            MangaSearchEntry firstMangaSearchResult = new MangaSearchEntry();

            if (index.Result.Content.ToString() == "1" || index.Result.Content.ToString() == "2" || index.Result.Content.ToString() == "3" || index.Result.Content.ToString() == "4" || index.Result.Content.ToString() == "5")
            {
                int x = Int32.Parse(index.Result.Content.ToString());
                firstMangaSearchResult = firstFiveResults.Take(5).ElementAt(x - 1);
            }
            else
            {
                await ctx.Channel.SendMessageAsync("`invalid input: request cancelled.`");

                return;
            }



            var resultEmbed = new DiscordEmbedBuilder
            {
                Title       = $"{firstMangaSearchResult.Title} ({firstMangaSearchResult.Type})",
                Description = $"{ firstMangaSearchResult.Description}",
                ImageUrl    = firstMangaSearchResult.ImageURL,
                Color       = DiscordColor.Azure,
                Url         = firstMangaSearchResult.URL,
            };

            resultEmbed.AddField("Score:", firstMangaSearchResult.Score.ToString());
            resultEmbed.AddField("Release Date:", firstMangaSearchResult.StartDate.ToString());
            resultEmbed.AddField("** **", $"**{firstMangaSearchResult.Chapters}** Chapters / **{firstMangaSearchResult.Volumes}** Volumes");
            resultEmbed.WithThumbnail("https://cdn.discordapp.com/attachments/779566889198157825/795191771315437579/apple-touch-icon-256.png"); //MAL ICON
            resultEmbed.WithFooter("source: MyAnimeList.net");
            await ctx.Channel.SendMessageAsync(embed : resultEmbed);
        }