A Fully Customizable Embed Pagination for DiscordJS V13 and V14
License: MIT License
JavaScript 100.00%
customizable-discordjs-pagination's Introduction
customizable-discordjs-pagination
This package features a fully customizable embed pagination for DiscordJS V13 and V14. The User can modify the buttons to their liking and enable/disable Select Menu.
Install package
npm install customizable-discordjs-pagination
Discord.js v13 Example
constPagination=require('customizable-discordjs-pagination');// Make Embeds using DiscordJS packageconstpages=[embed1,embed2,embed3];constbuttons=[{label: 'Previous',emoji: '⬅',style: 'DANGER'},{label: 'Next',emoji: '➡',style: 'SUCCESS'}];newPagination().setCommand(message).setPages(pages).setButtons(buttons).setPaginationCollector({timeout: 120000}).setSelectMenu({enable: true}).setFooter({enable: true}).send();
Discord.js v14 Example
constPagination=require('customizable-discordjs-pagination');const{ ButtonStyle }=require('discord.js');// Discord.js v14+// Make Embeds using DiscordJS packageconstpages=[embed1,embed2,embed3];constbuttons=[{label: 'Previous',emoji: '⬅',style: ButtonStyle.Danger},{label: 'Next',emoji: '➡',style: ButtonStyle.Success},]newPagination().setCommand(message).setPages(pages).setButtons(buttons).setPaginationCollector({timeout: 120000}).setSelectMenu({enable: true}).setFooter({enable: true}).send();
I'd like to be able to start on page 3 when listing hot topics from https://reddit.com/r/shogi (the first two pages are pinned topics). Yes, I could change the page order and make those pinned topics last (or if necessary, omit them, but these are full of resources that most players are interested in despite not wanting to see them every time).
If the message is ephemeral and the user dismisses the message before the timer is over to disable the buttons / end the collector, it throws an Unknown Message error when ending the collector because the message no longer exists.
Steps to reproduce
Send an ephemeral message with pages
Dismiss the message before the timeout
Wait for the timeout and you will notice the error
Suggested fixes
Add a .catch block
Return if its an ephemeral message, therefore don't do anything when the collector ends