private async Task Pagination(DiscordMessage message, int pageNum)
        {
            var result = await Interactivity.WaitForReactionAsync(react => {
                if (react.Message.Id != message.Id)
                {
                    return(false);
                }
                if (!LeftRightStop().Contains(react.Emoji.Name))
                {
                    return(false);
                }
                return(IsValidUser(react.User, react.Guild));
            }, Timeout);

            if (result.TimedOut)
            {
                FinalAction?.Invoke(message);
                return;
            }

            var newPageNum = pageNum;
            var e          = result.Result.Emoji.Name;

            if (e == Left)
            {
                if (newPageNum > 1)
                {
                    newPageNum--;
                }
            }
            else if (e == Right)
            {
                if (newPageNum < Pages)
                {
                    newPageNum++;
                }
            }
            else if (e == Stop)
            {
                FinalAction?.Invoke(message);
                return;
            }

            await result.Result.Message.DeleteReactionAsync(result.Result.Emoji, result.Result.User);

            var m = await message.ModifyAsync(embed : RenderPage(newPageNum));

            await Pagination(m, newPageNum);
        }
Ejemplo n.º 2
0
        private async Task Pagination(DiscordMessage message, int pageNum)
        {
            var result = await Interactivity.WaitForReactionAsync(react => {
                if (react.Message.Id != message.Id)
                {
                    return(false);
                }
                if (LeftRightStop().Contains(react.Emoji.Name))
                {
                    return(IsValidUser(react.User, react.Guild));
                }
                if (BigLeftRight().Contains(react.Emoji.Name))
                {
                    return(BulkSkipNumber > 1 && IsValidUser(react.User, react.Guild));
                }
                return(false);
            }, Timeout);

            if (result.TimedOut)
            {
                FinalAction?.Invoke(message);
                return;
            }

            var newPageNum = pageNum;
            var e          = result.Result.Emoji.Name;

            if (e == Left)
            {
                if (newPageNum == 1 && WrapPageEnds)
                {
                    newPageNum = Pages + 1;
                }
                if (newPageNum > 1)
                {
                    newPageNum--;
                }
            }
            else if (e == Right)
            {
                if (newPageNum == Pages && WrapPageEnds)
                {
                    newPageNum = 0;
                }
                if (newPageNum < Pages)
                {
                    newPageNum++;
                }
            }
            else if (e == BigLeft)
            {
                if (newPageNum > 1 || WrapPageEnds)
                {
                    for (int i = 1; (newPageNum > 1 || WrapPageEnds) && i < BulkSkipNumber; i++)
                    {
                        if (newPageNum == 1 && WrapPageEnds)
                        {
                            newPageNum = Pages + 1;
                        }
                        newPageNum--;
                    }
                }
            }
            else if (e == BigRight)
            {
                if (newPageNum < Pages || WrapPageEnds)
                {
                    for (int i = 1; (newPageNum < Pages || WrapPageEnds) && i < BulkSkipNumber; i++)
                    {
                        if (newPageNum == Pages && WrapPageEnds)
                        {
                            newPageNum = 0;
                        }
                        newPageNum++;
                    }
                }
            }
            else if (e == Stop)
            {
                FinalAction?.Invoke(message);
                return;
            }

            await result.Result.Message.DeleteReactionAsync(result.Result.Emoji, result.Result.User);

            var m = await message.ModifyAsync(content : Text?.Invoke(pageNum, Pages), embed : RenderPage(newPageNum));

            await Pagination(m, newPageNum);
        }