コード例 #1
0
        public async Task ImageSearch([Remainder] string query)
        {
            string qq = await PictureService.GetGoogleResult(query);

            dynamic stuff = JsonConvert.DeserializeObject(qq);

            Console.WriteLine(stuff.totalEstimatedMatches);
            var paginator = new LazyPaginatorBuilder()
                            .WithUsers(Context.User)
                            .WithPageFactory(PageFactory)
                            .WithMaxPageIndex(int.Parse(stuff.totalEstimatedMatches.ToString()) - 1)
                            .WithFooter(PaginatorFooter.PageNumber | PaginatorFooter.Users)
                            .WithDefaultEmotes()
                            .Build();

            Console.WriteLine(stuff.value[0].thumbnailUrl);
            //await Context.Channel.SendMessageAsync(stuff.value[0].thumbnailUrl.ToString());
            await Interactivity.SendPaginatorAsync(paginator, Context.Channel, TimeSpan.FromMinutes(2));

            Task <PageBuilder> PageFactory(int page)
            {
                return(Task.FromResult(new PageBuilder()
                                       //.WithText((page + 1).ToString())
                                       .WithTitle($"Image Result {page + 1}")
                                       .WithImageUrl(stuff.value[page].thumbnailUrl.ToString())
                                       .WithColor(System.Drawing.Color.FromArgb(page * 1500))));
            }
        }
コード例 #2
0
        public async Task Hentai([Remainder] string tags)
        {
            GalleryElement qq = await NHentaiService.getBook(tags);

            Console.WriteLine(qq.numPages);
            var paginator = new LazyPaginatorBuilder()
                            .WithUsers(Context.User)
                            .WithPageFactory(PageFactory)
                            .WithMaxPageIndex(int.Parse(qq.numPages.ToString()))
                            .WithFooter(PaginatorFooter.PageNumber | PaginatorFooter.Users)
                            .WithDefaultEmotes()
                            .Build();

            Console.WriteLine(qq.cover.imageUrl);
            //await Context.Channel.SendMessageAsync(stuff.value[0].thumbnailUrl.ToString());
            await Interactivity.SendPaginatorAsync(paginator, Context.Channel, TimeSpan.FromMinutes(2));

            Task <PageBuilder> PageFactory(int page)
            {
                return(Task.FromResult(new PageBuilder()
                                       //.WithText((page + 1).ToString())
                                       .WithTitle(qq.prettyTitle + $" Page {page + 1}")
                                       .WithImageUrl(qq.pages[page].imageUrl.ToString())
                                       .WithColor(System.Drawing.Color.FromArgb(page * 400))));
            }
        }
コード例 #3
0
        public async Task TeamMembersAsync([Name("TeamName")][Remainder] string name)
        {
            SendConstructionMessage();

            var team = await ScrapClient.GetTeamByNameAsync(name);

            await DeleteConstructionMessageAsync();

            if (team != null)
            {
                var pages = new List <PageBuilder>();

                var allMembers = await team.GetMembersAsync();

                var groups = allMembers.GroupBy(x => x.Rank);

                var leader = groups.Where(x => x.Key == Rank.Leader).First().First();
                pages.Add(PageUtils.LeaderPage(team, leader));

                if (groups.Where(x => x.Key == Rank.Coleader).Any())
                {
                    var coLeaders = groups.Where(x => x.Key == Rank.Coleader).First().OrderByDescending(x => x.Trophies).ToArray();
                    pages.AddRange(coLeaders.Chunk(10).Select(x => PageUtils.CoLeaderPage(team, x.ToArray())));
                }
                if (groups.Where(x => x.Key == Rank.Elder).Any())
                {
                    var elders = groups.Where(x => x.Key == Rank.Elder).First().OrderByDescending(x => x.Trophies).ToArray();
                    pages.AddRange(elders.Chunk(10).Select(x => PageUtils.ElderPage(team, x.ToArray())));
                }
                if (groups.Where(x => x.Key == Rank.Member).Any())
                {
                    var members = groups.Where(x => x.Key == Rank.Member).First().OrderByDescending(x => x.Trophies).ToArray();
                    pages.AddRange(members.Chunk(10).Select(x => PageUtils.MemberPage(team, x.ToArray())));
                }

                var paginator = new StaticPaginatorBuilder()
                                .WithDefaultEmotes()
                                .WithDeletion(DeletionOptions.AfterCapturedContext | DeletionOptions.Valid)
                                .WithUsers(Context.User)
                                .WithPages(pages)
                                .Build();

                await Interactivity.SendPaginatorAsync(paginator, Context.Channel);
            }
            else
            {
                await ReplyAsync(embed : EmbedUtils.NotFoundEmbed("Team", name));
            }
        }
コード例 #4
0
        private async Task LeaderboardAsync <T>(T[] values, Func <T, string> nameSelector, Func <T, string> valueSelector,
                                                string entityName, string valueName, Color color)
        {
            var pages = new List <PageBuilder>();
            int index = 0;

            foreach (var chunk in values.Chunk(PageSize))
            {
                pages.Add(PageUtils.LeaderBoardPage(chunk, index, nameSelector, valueSelector, entityName, valueName, color));
                index += PageSize;
            }

            var paginator = new StaticPaginatorBuilder()
                            .WithDefaultEmotes()
                            .WithDeletion(DeletionOptions.Valid)
                            .WithUsers(Context.User)
                            .WithPages(pages.ToArray())
                            .Build();

            await Interactivity.SendPaginatorAsync(paginator, Context.Channel);
        }