public override Paginator Build(int startPage = 0)
        {
            if (Pages.Count == 0)
            {
                throw new InvalidOperationException("A paginator needs at least one page!");
            }

            if (Emotes.Count == 0)
            {
                WithDefaultEmotes();
            }

            for (int i = 0; i < Pages.Count; i++)
            {
                Pages[i].WithPaginatorFooter(Footer, i, Pages.Count - 1, Users);
            }

            return(new StaticPaginator(Users?.AsReadOnly() ?? throw new ArgumentNullException(nameof(Users)),
                                       Emotes?.AsReadOnly() ?? throw new ArgumentNullException(nameof(Emotes)),
                                       CancelledEmbed?.Build(),
                                       TimeoutedEmbed?.Build(),
                                       Deletion,
                                       Pages?.Select(x => x.Build()).ToList().AsReadOnly() ?? throw new ArgumentNullException(nameof(Pages)),
                                       startPage));
        }
示例#2
0
        public override Paginator Build(int startPage = 0)
        {
            if (Emotes.Count == 0)
            {
                WithDefaultEmotes();
            }

            return(new LazyPaginator(Users?.AsReadOnly() ?? throw new ArgumentNullException(nameof(Users)),
                                     Emotes?.AsReadOnly() ?? throw new ArgumentNullException(nameof(Emotes)),
                                     CancelledEmbed?.Build(),
                                     TimeoutedEmbed?.Build(),
                                     Deletion,
                                     AddPaginatorFooterAsync,
                                     startPage,
                                     MaxPageIndex));

            async Task <Page> AddPaginatorFooterAsync(int page)
            {
                var builder = await PageFactory.Invoke(page).ConfigureAwait(false);

                return(builder?.WithPaginatorFooter(Footer, page, MaxPageIndex, Users)
                       .Build());
            }
        }