/// <summary> /// Adds found anime search entry to specific user's list asynchronously. /// </summary> /// <param name="searchEntry">The search entry you found.</param> /// <param name="status">The status of the anime Watching, Completed, Onhold, Dropped...</param> /// <returns>A string represnting the state of adding "Created" or detailed error message.</returns> public async Task <string> AddAnimeAsync(AnimeSearchEntry searchEntry, AnimeListStatus status) { m_api.CheckAuthAsync(); AnimeEntry addedAnime = new AnimeEntry() { Status = status, }; return(await m_api.PostSerializedObjectAsync(addedAnime, string.Format(MAL.url_addAnime, searchEntry.Id))); }
public AnimeDetailsPage(AnimeSearchEntry anime) { if (anime == null) { throw new ArgumentNullException(nameof(anime)); } _anime = anime; InitializeComponent(); }
/// <summary> /// Adds found anime search entry to specific user's list. /// </summary> /// <param name="searchEntry">The search entry you found.</param> /// <param name="status">The status of the anime Watching, Completed, Onhold, Dropped...</param> /// <returns>A string represnting the state of adding "Created" or detailed error message.</returns> public string AddAnime(AnimeSearchEntry searchEntry, AnimeListStatus status) { m_api.CheckAuth(); AnimeEntry addedAnime = new AnimeEntry() { Status = status, }; return(m_api.PostSerializedObject(addedAnime, string.Format(MAL.url_addAnime, searchEntry.Id))); }
public async Task <ActionResult <AnimeInfo> > GetAnimeInfos(string id) { IJikan jikan = new Jikan(); AnimeInfo animeInfo = new AnimeInfo(); AnimeSearchResult animes = await jikan.SearchAnime(id); if (animes.Results.Count <= 0) { animeInfo.Title = "nsrf"; } else { AnimeSearchEntry firstFound = animes.Results.First(); animeInfo.Title = firstFound.Title; animeInfo.ReleaseDate = firstFound.StartDate.Value.ToShortDateString(); animeInfo.NumberOfEpisodes = firstFound.Episodes.GetValueOrDefault(); animeInfo.Summary = firstFound.Description; } return(animeInfo); }
public async Task AnimeSearch(CommandContext ctx, [RemainingText] string title) { var isShort = await IsTitleShort(title, ctx); if (isShort == true) { return; } var interactivity = ctx.Client.GetInteractivity(); IJikan jikan = new Jikan(true); AnimeSearchResult animeSearchResult = await jikan.SearchAnime(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); AnimeSearchEntry firstAnimeResult = new AnimeSearchEntry(); 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()); firstAnimeResult = firstFiveResults.Take(5).ElementAt(x - 1); } else { await ctx.Channel.SendMessageAsync("`invalid input: request cancelled.`"); return; } #region Creating and Sending Anime Embed var resultEmbed = new DiscordEmbedBuilder { Title = $"{firstAnimeResult.Title} ({firstAnimeResult.Type})", Description = $"{ firstAnimeResult.Description}", ImageUrl = firstAnimeResult.ImageURL, Color = DiscordColor.Azure, Url = firstAnimeResult.URL, }; resultEmbed.AddField("Score:", firstAnimeResult.Score.ToString()); resultEmbed.AddField("Rating:", firstAnimeResult.Rated); resultEmbed.AddField("Release Date:", firstAnimeResult.StartDate.ToString()); resultEmbed.WithThumbnail("https://cdn.discordapp.com/attachments/779566889198157825/795191771315437579/apple-touch-icon-256.png"); //MAL ICON resultEmbed.WithFooter("Source: MyAnimeList.net"); if (firstAnimeResult.Title == "Boku no Pico") { await ctx.Channel.SendMessageAsync(embed : resultEmbed); await ctx.Channel.SendMessageAsync("`Sir, the man you're looking for is right here.`"); } else if (firstAnimeResult.Rated.ToString() == "Rx" && ctx.Channel.IsNSFW == false) { await ctx.Channel.SendMessageAsync("`This anime can only be shown in a NSFW channel only.`"); } else { await ctx.Channel.SendMessageAsync(embed : resultEmbed); } #endregion }