public async Task <RuntimeResult> ListAvailablePatternsAsync()
        {
            var parts = Enum.GetValues(typeof(Pattern))
                        .Cast <Pattern>()
                        .OrderBy(c => c);

            var options = new PaginatedAppearanceOptions
            {
                Color = Color.DarkPurple
            };

            var paginatedMessage = PaginatedEmbedFactory.SimpleFieldsFromCollection
                                   (
                _feedback,
                _interactivity,
                this.Context.User,
                parts,
                b => b.Humanize(),
                b => "\u200B",
                appearance: options
                                   );

            await _interactivity.SendInteractiveMessageAsync(this.Context.Channel, paginatedMessage);

            return(RuntimeCommandResult.FromSuccess());
        }
Esempio n. 2
0
        public OkResult(IEnumerable <EmbedBuilder> pages, uint pageSplit = 0, Color?color = null, IGuildUser author = null,
                        VolteContext ctx = null, string title = null, PaginatedAppearanceOptions options            = null)
        {
            _pager = PaginatedMessage.Builder.New
                     .WithPages(pages);

            if (color.HasValue)
            {
                _pager.WithColor(color.Value);
            }
            if (author != null)
            {
                _pager.WithAuthor(author);
            }
            if (ctx != null)
            {
                _pager.WithDefaults(ctx);
            }
            if (title != null)
            {
                _pager.WithTitle(title);
            }
            if (options != null)
            {
                _pager.WithOptions(options);
            }
            if (pageSplit > 0)
            {
                _pager.SplitPages(pageSplit);
            }
        }
Esempio n. 3
0
        public async Task ReadingHen(int henId)
        {
            try
            {
                var book = await _hentai.SearchBookAsync(henId);

                var pages = book.GetPages().ToList();

                var paging = pages
                             .Select(result => new EmbedPage
                {
                    Title = $"**{book.Titles.Japanese}**",
                    AlternateAuthorTitle = "Nhentai",
                    AlternateAuthorIcon  = "https://i.4cdn.org/h/1605807858643.png",
                    ImageUrl             = result,
                    TimeStamp            = Now,
                    Url = $"https://nhentai.net/g/" + $"{book.Id}/"
                }).ToList();

                var options = new PaginatedAppearanceOptions
                {
                    Next    = new Emoji("▶️"),
                    Back    = new Emoji("◀️"),
                    Last    = new Emoji("↪️"),
                    First   = new Emoji("↩️"),
                    Timeout = TimeSpan.FromMinutes(15)
                };
                var paginatedMessage = new PaginatedMessage
                {
                    Pages          = paging,
                    Content        = "**Happy reading, this embed will expire in 15 minutes**",
                    Options        = options,
                    FooterOverride = new EmbedFooterBuilder().WithText($"Requested by {Context.User.Username}")
                                     .WithIconUrl(Context.User.GetAvatarUrl() ?? Context.User.GetDefaultAvatarUrl()),
                    TimeStamp = Now,
                    Color     = new Color(Utils.RandomColor(), Utils.RandomColor(), Utils.RandomColor())
                };
                await PagedReplyAsync(paginatedMessage, new ReactionList());
            }
            catch
            {
                await Context.Channel.SendErrorAsync("Not found",
                                                     "Our engine can't find anything using your provided id");
            }
        }
        public async Task <RuntimeResult> ListAvailableBodypartsAsync()
        {
            var parts = Enum.GetValues(typeof(Bodypart))
                        .Cast <Bodypart>()
                        .OrderBy(b => b);

            var options = new PaginatedAppearanceOptions
            {
                Color = Color.DarkPurple
            };

            var paginatedMessage = PaginatedEmbedFactory.SimpleFieldsFromCollection
                                   (
                _feedback,
                _interactivity,
                this.Context.User,
                parts,
                b => b.Humanize(),
                b =>
            {
                if (b.IsChiral())
                {
                    return("This part is available in both left and right versions.");
                }

                if (!b.IsGenderNeutral())
                {
                    return("This part is considered NSFW.");
                }

                if (b.IsComposite())
                {
                    return("This part is composed of smaller parts.");
                }

                return("This is a normal bodypart.");
            },
                appearance: options
                                   );

            await _interactivity.SendInteractiveMessageAsync(this.Context.Channel, paginatedMessage);

            return(RuntimeCommandResult.FromSuccess());
        }
        public async Task Test_Paginator()
        {
            // Use an object initializer ideally. This code is written the way it is for demonstration purposes.
            var pages = new List <EmbedPage>();

            var p1 = new EmbedPage
            {
                Title       = "First Page",
                Description = "Interesting Information",
            };

            var p2 = new EmbedPage
            {
                Title = "Second Page",
                AlternateAuthorTitle = Context.User.Username,
                AlteranteAuthorIcon  = Context.User.GetAvatarUrl()
            };

            var p3 = new EmbedPage
            {
                ImageUrl = "https://img2.gelbooru.com/samples/a5/9c/sample_a59c7a3eefe67b062ea37825ce6cea83.jpg",
            };

            pages.Add(p1);
            pages.Add(p2);
            pages.Add(p3);

            var options = new PaginatedAppearanceOptions
            {
                InformationText = "This fancy embed is called a Paginator",
                Timeout         = TimeSpan.FromSeconds(30),
            };

            var pagedEmbed = new PaginatedMessage
            {
                Pages          = pages,
                Options        = options,
                FooterOverride = new EmbedFooterBuilder().WithText("Nice Footer")
            };

            await PagedReplyAsync(pagedEmbed, new ReactionList());
        }
Esempio n. 6
0
        public async Task Help()
        {
            Collection <string> Pages = new Collection <string>();

            var  guild  = Program.Guilds.GetValueOrDefault(Context.Guild.Id);
            char prefix = guild.Prefix;

            string txt = "Contents:";
            int    i   = 1;

            foreach (var item in _commands.Modules.Where(m => m.Parent == null))
            {
                if (item.Name != "Help")
                {
                    i++;
                    GetContents(i, item, ref txt);
                }
            }
            Pages.Add(txt);

            foreach (var mod in _commands.Modules.Where(m => m.Parent == null))
            {
                if (mod.Name != "Help")
                {
                    Pages.Add(AddHelp(prefix, mod));
                }
            }

            var options = new PaginatedAppearanceOptions()
            {
                DisplayInformationIcon = false, JumpDisplayOptions = 0
            };
            var pages = Pages.AsEnumerable <object>();

            var final = new PaginatedMessage()
            {
                Title = $"**{Program.CurrentName} Helper!**", Color = new Color(await Program.GetUserColour(Context.Message.Author.Id)), Options = options, Pages = pages
            };

            await PagedReplyAsync(final, false);
        }
Esempio n. 7
0
        public async Task ListAvailableShadeModifiersAsync()
        {
            var parts = Enum.GetValues(typeof(ShadeModifier))
                        .Cast <ShadeModifier>()
                        .OrderBy(sm => sm);

            var options = new PaginatedAppearanceOptions
            {
                Color = Color.DarkPurple
            };

            var paginatedMessage = PaginatedEmbedFactory.SimpleFieldsFromCollection
                                   (
                _feedback,
                this.Context.User,
                parts,
                b => b.Humanize(),
                b => "\u200B",
                appearance: options
                                   );

            await _interactivity.SendInteractiveMessageAsync(this.Context.Channel, paginatedMessage);
        }
Esempio n. 8
0
        public async Task Recommend([Remainder] string query)
        {
            if (query.Length < 3)
            {
                await Context.Channel.SendErrorAsync("Your input must have at least 3 characters !",
                                                     "Please try again!");

                return;
            }

            var animeSearchConfig = new AnimeSearchConfig
            {
                Type = AnimeType.EveryType
            };
            var animeSearchResult = await _jikan.SearchAnime($"{query}", animeSearchConfig);

            var animeSearch = animeSearchResult.Results;

            if (animeSearch == null)
            {
                await Context.Channel.SendErrorJikanAsync($"Not found any anime for {query}",
                                                          "Error ! Please recheck your spelling", Context.User);

                return;
            }

            var animeSearchEntry = EvaluateAnime(query, animeSearch);
            //Computing misses
            //var computing = LevenshteinDistanceComputingService.Evaluation(query.ToLower(), animeSearchEntry.Title.ToLower());
            var percentage = query.Length / (double)animeSearchEntry.Title.Length * 100;

            if (percentage >= 33)
            {
                var episodes = await _jikan.GetAnimeEpisodes(animeSearchEntry.MalId).ConfigureAwait(false);

                var pages = episodes.EpisodeCollection.Select(result => new EmbedPage
                {
                    Title       = $"**{result.Title}**",
                    Description = $"Have anything to discuss with other viewers ? " +
                                  $"\nClick here to enter the MAL forum! " +
                                  $"\n**[Forum]({result.ForumUrl})**",
                    AlternateAuthorTitle = "MyAnimeList",
                    AlternateAuthorIcon  = "https://cdn.myanimelist.net/img/sp/icon/apple-touch-icon-256.png",
                    Url       = result.VideoUrl,
                    TimeStamp = Now,
                    ImageUrl  = $"{animeSearchEntry.ImageURL}"
                })
                            .ToList();
                var options = new PaginatedAppearanceOptions
                {
                    InformationText = $"**Episodes list for [{animeSearchEntry.Title}]**",
                    Next            = new Emoji("▶️"),
                    Back            = new Emoji("◀️"),
                    Last            = new Emoji("↪️"),
                    First           = new Emoji("↩️"),
                    Timeout         = TimeSpan.FromSeconds(60)
                };
                var paginatedMessage = new PaginatedMessage
                {
                    Pages   = pages,
                    Content =
                        $"**Showing episodes details for [{animeSearchEntry.Title}]**",
                    Options        = options,
                    FooterOverride = new EmbedFooterBuilder().WithText($"Requested by {Context.User.Username}")
                                     .WithIconUrl(Context.User.GetAvatarUrl() ?? Context.User.GetDefaultAvatarUrl()),
                    TimeStamp = Now,
                    Color     = new Color(Utils.RandomColor(), Utils.RandomColor(), Utils.RandomColor())
                };
                await PagedReplyAsync(paginatedMessage, new ReactionList());
            }
            else
            {
                await Context.Channel.SendErrorJikanAsync("Match percentage is below 33%",
                                                          $"We can't not find any suitable anime and its episodes with input : [{query}]", Context.User);
            }
        }
Esempio n. 9
0
        public async Task FetchAnime([Remainder] string query)
        {
            if (query.Length < 3)
            {
                await Context.Channel.SendErrorAsync("Your input must have at least 3 characters !",
                                                     "Please try again!");

                return;
            }

            var animeSearchConfig = new AnimeSearchConfig
            {
                Type = AnimeType.EveryType
            };
            var animeSearchResult = await _jikan.SearchAnime($"{query}", animeSearchConfig);

            var animeSearch = animeSearchResult.Results;

            if (animeSearch == null)
            {
                await Context.Channel.SendErrorJikanAsync($"Not found any anime for {query}",
                                                          "Error ! Please recheck your spelling", Context.User);

                return;
            }

            var animeSearchEntry = EvaluateAnime(query, animeSearch);
            //Computing misses
            //var computing = LevenshteinDistanceComputingService.Evaluation(query.ToLower(), animeSearchEntry.Title.ToLower());
            var percentage = query.Length / (double)animeSearchEntry.Title.Length * 100;

            #region Anime version and spinoff

            /*
             * var animeVer = await _jikan.GetAnime(animeSearchEntry.MalId);
             * var sb = new StringBuilder();
             * if (animeVer.Related.SpinOffs != null)
             *  foreach (var spinOff in animeVer.Related.SpinOffs)
             *      sb.AppendLine("Spinoff : " + spinOff.Name + $"\nMAL link : [Click here]({spinOff.Url})");
             *
             * if (animeVer.Related.Sequels != null)
             *  foreach (var sequel in animeVer.Related.Sequels)
             *      sb.AppendLine("Sequel : " + sequel.Name + $"\nMAL link : [Click here]({sequel.Url})");
             *
             * if (animeVer.Related.AlternativeVersions != null)
             *  foreach (var alter in animeVer.Related.AlternativeVersions)
             *      sb.AppendLine("Alternative : " + alter.Name + $"\nMAL link : [Click here]({alter.Url})");
             *
             * if (animeVer.Related.AlternativeSettings != null)
             *  foreach (var alterS in animeVer.Related.AlternativeSettings)
             *      sb.AppendLine("Alternative : " + alterS.Name + $"\nMAL link : [Click here]({alterS.Url})");
             *
             * if (animeVer.Related.Adaptations != null)
             *  foreach (var adaption in animeVer.Related.Adaptations)
             *      sb.AppendLine("Adaption : " + adaption.Name + $"\nMAL link : [Click here]({adaption.Url})");
             *
             * if (animeVer.Related.Prequels != null)
             *  foreach (var prequel in animeVer.Related.Prequels)
             *      sb.AppendLine("Prequel : " + prequel.Name + $"\nMAL link : [Click here]({prequel.Url})");
             *
             */

            #endregion

            if (percentage >= 33)
            {
                await Context.Channel.SendSuccessAnimeAsync($"Found anime for [{query}]",
                                                            $"{animeSearchEntry.Title}",
                                                            $"{animeSearchEntry.Rated}",
                                                            $"{animeSearchEntry.Score}",
                                                            $"{animeSearchEntry.Episodes}",
                                                            $"{animeSearchEntry.Description}",
                                                            $"{animeSearchEntry.URL}",
                                                            animeSearchEntry.ImageURL, Context.User);
            }
            else
            {
                var pages = new List <EmbedPage>();
                var count = 0;
                foreach (var result in animeSearch)
                {
                    var page = new EmbedPage
                    {
                        Title                = $"**{result.Title}**",
                        Description          = result.Description,
                        AlternateAuthorTitle = "MyAnimeList",
                        AlternateAuthorIcon  = "https://cdn.myanimelist.net/img/sp/icon/apple-touch-icon-256.png",
                        ThumbnailUrl         = result.ImageURL,
                        Url       = result.URL,
                        TimeStamp = Now
                    };
                    count++;
                    if (count == 6)
                    {
                        break;
                    }
                    pages.Add(page);
                }

                var options = new PaginatedAppearanceOptions
                {
                    InformationText = $"**Possible result for [{query}]**",
                    Next            = new Emoji("▶️"),
                    Back            = new Emoji("◀️"),
                    Last            = new Emoji("↪️"),
                    First           = new Emoji("↩️"),
                    Timeout         = TimeSpan.FromSeconds(60)
                };

                var paginatedMessage = new PaginatedMessage
                {
                    Pages   = pages,
                    Content =
                        $"**Showing maximum of 5 possible options for [{query}] since threshold for match is below 33%**",
                    Options        = options,
                    FooterOverride = new EmbedFooterBuilder().WithText($"Requested by {Context.User.Username}")
                                     .WithIconUrl(Context.User.GetAvatarUrl() ?? Context.User.GetDefaultAvatarUrl()),
                    TimeStamp = Now,
                    Color     = new Color(Utils.RandomColor(), Utils.RandomColor(), Utils.RandomColor())
                };
                await PagedReplyAsync(paginatedMessage, new ReactionList());
            }
        }
Esempio n. 10
0
        public async Task FetchManga([Remainder] string query)
        {
            if (query.Length < 3)
            {
                await Context.Channel.SendErrorAsync("Your input must have at least 3 characters !",
                                                     "Please try again!");

                return;
            }

            var mangaSearchConfig = new MangaSearchConfig
            {
                Type = MangaType.EveryType
            };
            var mangaSearchResult = await _jikan.SearchManga($"{query}", mangaSearchConfig);

            var mangaSearch = mangaSearchResult.Results;

            if (mangaSearch == null)
            {
                await Context.Channel.SendErrorJikanAsync($"Not found any manga for {query}",
                                                          "Error ! Please recheck your spelling", Context.User);

                return;
            }

            var mangaSearchEntry = EvaluateManga(query, mangaSearch);
            var percentage       = query.Length / (double)mangaSearchEntry.Title.Length * 100;

            if (percentage >= 33)
            {
                await Context.Channel.SendSuccessMangaAsync($"Found manga for [{query}]",
                                                            $"{mangaSearchEntry.Title}",
                                                            $"{mangaSearchEntry.Type}",
                                                            $"{mangaSearchEntry.Score}",
                                                            $"{mangaSearchEntry.Description}",
                                                            $"{mangaSearchEntry.URL}",
                                                            mangaSearchEntry.ImageURL, Context.User);
            }
            else
            {
                var pages = new List <EmbedPage>();
                var count = 0;
                foreach (var result in mangaSearch)
                {
                    var page = new EmbedPage
                    {
                        Title                = $"**{result.Title}**",
                        Description          = result.Description,
                        AlternateAuthorTitle = "MyAnimeList",
                        AlternateAuthorIcon  = "https://cdn.myanimelist.net/img/sp/icon/apple-touch-icon-256.png",
                        ThumbnailUrl         = result.ImageURL,
                        Url       = result.URL,
                        TimeStamp = Now
                    };
                    count++;
                    if (count == 6)
                    {
                        break;
                    }
                    pages.Add(page);
                }

                var options = new PaginatedAppearanceOptions
                {
                    InformationText = $"**Possible result for [{query}]**",
                    Next            = new Emoji("▶️"),
                    Back            = new Emoji("◀️"),
                    Last            = new Emoji("↪️"),
                    First           = new Emoji("↩️"),
                    Timeout         = TimeSpan.FromSeconds(60)
                };

                var paginatedMessage = new PaginatedMessage
                {
                    Pages   = pages,
                    Content =
                        $"**Showing maximum of 5 possible options for [{query}] since threshold for match is below 33%**",
                    Options        = options,
                    FooterOverride = new EmbedFooterBuilder().WithText($"Requested by {Context.User.Username}")
                                     .WithIconUrl(Context.User.GetAvatarUrl() ?? Context.User.GetDefaultAvatarUrl()),
                    TimeStamp = Now,
                    Color     = new Color(Utils.RandomColor(), Utils.RandomColor(), Utils.RandomColor())
                };
                await PagedReplyAsync(paginatedMessage, new ReactionList());
            }
        }
Esempio n. 11
0
        public static PaginatedMessage printAchievementsStatus(Color color, ulong guildId, ulong clientId,
                                                               string username, string thumbnailUrl)
        {
            Boolean achievementDataExists = false;

            PaginatedAppearanceOptions pao = new PaginatedAppearanceOptions();

            pao.JumpDisplayOptions     = JumpDisplayOptions.Never;
            pao.DisplayInformationIcon = false;

            List <string> pageContent = new List <string>();

            string title        = "";
            string tempVal      = title;
            int    currentIndex = 0;

            for (int i = 0; i < achievementList.Count; i++)
            {
                string   achievementKey = achievementList.ElementAt(i).Key;
                string[] arrMaster      = achievementList[achievementKey];//format: title, description
                string   mTitle         = arrMaster[0];
                string   mDesc          = arrMaster[1];

                if (!achievementDataExists)
                {
                    tempVal += ":white_check_mark: ";
                }
                else
                {
                    tempVal += ":x: ";
                }

                tempVal += $"**{mTitle}**\n{mDesc}\n";

                if (i == achievementList.Count - 1)
                {
                    pageContent.Add(tempVal);
                }
                else
                {
                    if (currentIndex < 9)
                    {
                        currentIndex++;
                    }
                    else
                    {
                        pageContent.Add(tempVal);
                        currentIndex = 0;
                        tempVal      = title;
                    }
                }
            }

            var pager = new PaginatedMessage
            {
                Title  = $"**{username}'s Achievements**\n",
                Pages  = pageContent,
                Color  = color,
                Author = new EmbedAuthorBuilder()
                {
                    Name    = GlobalFunctions.UppercaseFirst(username),
                    IconUrl = thumbnailUrl
                },
                Options = pao
            };

            return(pager);
        }