Beispiel #1
0
        public static async Task <List <MangaDataModel> > GetManga(string input, int loop = 10)
        {
            try
            {
                var reply = await Manga.GetMangaAsync(input);

                var list = new List <MangaDataModel>();
                if (reply.Data.Count > loop)
                {
                    for (int i = 0; i < loop; i++)
                    {
                        list.Add(reply.Data[i]);
                    }
                }
                else
                {
                    for (int i = 0; i < reply.Data.Count; i++)
                    {
                        list.Add(reply.Data[i]);
                    }
                }
                return(list);
            }
            catch
            {
                return(null);
            }
        }
Beispiel #2
0
        public async Task MangaAsync([Remainder, Name("manga_name")] string args)
        {
            var manga = await Manga.GetMangaAsync(args);

            await Context.Channel.TriggerTypingAsync();

            var embed = new EmbedBuilder
            {
                Color        = new Color(33, 176, 252),
                Title        = manga.Data[0].Attributes.CanonicalTitle ?? manga.Data[0].Attributes.Titles.JaJp,
                Description  = manga.Data[0].Attributes.Synopsis,
                ThumbnailUrl = manga.Data[0].Attributes.PosterImage.Medium
            }.Build();

            await ReplyAsync("", embed : embed);
        }
Beispiel #3
0
        public async Task GetMangaAsync([Remainder] string mangatitle)
        {
            using var Database = new SkuldDbContextFactory().CreateDbContext();

            var usr = await Database
                      .InsertOrGetUserAsync(Context.User)
                      .ConfigureAwait(false);

            var loc = Locale.GetLocale(
                usr.Language ?? Locale.DefaultLocale
                );

            var raw = await Manga
                      .GetMangaAsync(mangatitle)
                      .ConfigureAwait(false);

            var data = raw.Data;

            if (data.Count > 1) // do pagination
            {
                var pages = data.PaginateList(25);

                IUserMessage sentmessage = await ReplyAsync(
                    null,
                    false,
                    EmbedExtensions
                    .FromMessage(
                        loc.GetString("SKULD_SEARCH_MKSLCTN") + " 30s",
                        pages[0],
                        Context
                        )
                    .WithColor(Color.Purple)
                    .Build()
                    ).ConfigureAwait(false);

                var response = await NextMessageAsync(
                    true,
                    true,
                    TimeSpan.FromSeconds(30)
                    ).ConfigureAwait(false);

                if (response is null)
                {
                    await sentmessage.DeleteAsync().ConfigureAwait(false);

                    return;
                }

                var selection = Convert.ToInt32(response.Content);

                var manga = data[selection - 1];

                await manga
                .ToEmbed(loc)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            }
            else
            {
                var manga = data[0];

                await manga
                .ToEmbed(loc)
                .QueueMessageAsync(Context)
                .ConfigureAwait(false);
            }
        }
Beispiel #4
0
        public async Task MangaGet(CommandContext ctx, [RemainingText] string search)
        {
            try
            {
                var ine = ctx.Client.GetInteractivity();
                var a   = await Manga.GetMangaAsync(search);

                var emb = new DiscordEmbedBuilder();
                List <DiscordEmbedBuilder> res = new();
                List <Page> ress = new();
                foreach (var aa in a.Data)
                {
                    emb.WithColor(new DiscordColor(0212255));
                    emb.WithTitle(aa.Attributes.Titles.EnJp);
                    if (aa.Attributes.Synopsis != null)
                    {
                        emb.WithDescription(aa.Attributes.Synopsis);
                    }
                    if (aa.Attributes.Subtype != null)
                    {
                        emb.AddField("Type", $"{aa.Attributes.Subtype}", true);
                    }
                    if (aa.Attributes.StartDate != null)
                    {
                        emb.AddField("Start Date", $"{aa.Attributes.StartDate}", true);
                    }
                    if (aa.Attributes.EndDate != null)
                    {
                        emb.AddField("End Date", $"{aa.Attributes.EndDate}", true);
                    }
                    if (aa.Attributes.AgeRating != null)
                    {
                        emb.AddField("Age Rating", $"{aa.Attributes.AgeRating}", true);
                    }
                    if (aa.Attributes.AverageRating != null)
                    {
                        emb.AddField("Score", $"{aa.Attributes.AverageRating}", true);
                    }
                    if (aa.Attributes.CoverImage?.Small != null)
                    {
                        emb.WithThumbnail(aa.Attributes.CoverImage.Small);
                    }
                    emb.WithFooter("via Kitsu.io", "https://kitsu.io/kitsu-256-ed442f7567271af715884ca3080e8240.png");
                    res.Add(emb);
                    emb = new DiscordEmbedBuilder();
                }
                res.Sort((x, y) => x.Title.CompareTo(y.Title));
                int i = 1;
                foreach (var aa in res)
                {
                    aa.WithFooter($"via Kitsu.io -- Page {i}/{a.Data.Count}", "https://kitsu.io/kitsu-256-ed442f7567271af715884ca3080e8240.png");
                    ress.Add(new Page(embed: aa));
                    i++;
                }
                await ine.SendPaginatedMessageAsync(ctx.Channel, ctx.User, ress, PaginationBehaviour.WrapAround, ButtonPaginationBehavior.Disable);
            }
            catch
            {
                await ctx.RespondAsync("No Manga Found!");
            }
        }
Beispiel #5
0
        public async Task KitsuMangaAsync([Remainder] string mangaSearch)
        {
            EmbedBuilder kitsuMangaEmbed = new EmbedBuilder();

            var    chapterCount = "";
            string rating       = "";

            try
            {
                var mangas = await Manga.GetMangaAsync(mangaSearch);

                foreach (var manga in mangas.Data)
                {
                    if (manga.Attributes.Titles.EnJp != "")
                    {
                        if (manga.Attributes.ChapterCount == null)
                        {
                            chapterCount = "Unknown";
                        }

                        else
                        {
                            chapterCount = manga.Attributes.ChapterCount.ToString();
                        }

                        if (manga.Attributes.AverageRating == null)
                        {
                            rating = "Unknown";
                        }

                        else
                        {
                            rating = manga.Attributes.AverageRating;
                        }

                        string mangaStatus = char.ToUpper(manga.Attributes.Status.First()) + manga.Attributes.Status.Substring(1);

                        string mangaType = char.ToUpper(manga.Attributes.Subtype.First()) + manga.Attributes.Subtype.Substring(1);

                        kitsuMangaEmbed
                        .WithTitle(manga.Attributes.Titles.EnJp)
                        .WithUrl("https://kitsu.io/manga/" + manga.Attributes.Slug)
                        .WithThumbnailUrl(manga.Attributes.PosterImage.Original)
                        .AddInlineField("Status:", mangaStatus)
                        .AddInlineField("Chapters:", chapterCount)
                        .AddInlineField("Rating:", rating)
                        .AddInlineField("Type:", mangaType)
                        .WithDescription($"{manga.Attributes.Synopsis}")
                        .WithFooter("Kitsu.io", "https://pbs.twimg.com/profile_images/807964865511862278/pIYOVdsl_400x400.jpg");

                        await ReplyAsync("", false, kitsuMangaEmbed.Build());

                        break;
                    }
                }
            }

            catch (NoDataFoundException e)
            {
                await ReplyAsync(e.Message);
            }
        }