Пример #1
0
        public PagedView(PageProvider pageProvider, LocalMessage templateMessage = null)
            : base(pageProvider, templateMessage)
        {
            FirstPageButton = new ButtonViewComponent(OnFirstPageButtonAsync)
            {
                Emoji = new LocalEmoji("⏮️"),
                Style = LocalButtonComponentStyle.Secondary
            };
            PreviousPageButton = new ButtonViewComponent(OnPreviousPageButtonAsync)
            {
                Emoji = new LocalEmoji("◀️"),
                Style = LocalButtonComponentStyle.Secondary
            };
            NextPageButton = new ButtonViewComponent(OnNextPageButtonAsync)
            {
                Emoji = new LocalEmoji("▶️"),
                Style = LocalButtonComponentStyle.Secondary
            };
            LastPageButton = new ButtonViewComponent(OnLastPageButtonAsync)
            {
                Emoji = new LocalEmoji("⏭️"),
                Style = LocalButtonComponentStyle.Secondary
            };
            StopButton = new ButtonViewComponent(OnStopButtonAsync)
            {
                Emoji = new LocalEmoji("⏹️"),
                Style = LocalButtonComponentStyle.Secondary
            };

            AddComponent(FirstPageButton);
            AddComponent(PreviousPageButton);
            AddComponent(NextPageButton);
            AddComponent(LastPageButton);
            AddComponent(StopButton);
        }
Пример #2
0
        protected internal override sealed async Task <IUserMessage> InitialiseAsync()
        {
            var page = await PageProvider.GetPageAsync(this).ConfigureAwait(false);

            var message = await Channel.SendMessageAsync(page.Content, embed : page.Embed).ConfigureAwait(false);

            return(message);
        }
Пример #3
0
        public async Task ChangePageAsync(int pageIndex)
        {
            if (pageIndex < 0 || pageIndex > PageProvider.PageCount - 1)
            {
                return;
            }

            CurrentPageIndex = pageIndex;
            var page = await PageProvider.GetPageAsync(this).ConfigureAwait(false);

            await Message.ModifyAsync(x =>
            {
                x.Content = page.Content;
                x.Embed   = page.Embed;
            }).ConfigureAwait(false);

            await PageChangedAsync().ConfigureAwait(false);
        }