npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

customizable-discordjs-pagination

v2.1.1

Published

A Fully Customizable Embed Pagination for DiscordJS

Downloads

224

Readme

customizable-discordjs-pagination

Install package

npm install customizable-discordjs-pagination

Discord.js v13 Example

const Pagination = require('customizable-discordjs-pagination');

// Make Embeds using DiscordJS package
const pages = [embed1, embed2, embed3];

const buttons = [
   { label: 'Previous', emoji: '⬅', style: 'DANGER' },
   { label: 'Next', emoji: '➡', style: 'SUCCESS' }
];

new Pagination()
   .setCommand(message)
   .setPages(pages)
   .setButtons(buttons)
   .setPaginationCollector({ timeout: 120000 })
   .setSelectMenu({ enable: true })
   .setFooter({ enable: true })
   .send();

Discord.js v14 Example

const Pagination = require('customizable-discordjs-pagination');
const { ButtonStyle } = require('discord.js'); // Discord.js v14+

// Make Embeds using DiscordJS package
const pages = [embed1, embed2, embed3];

const buttons = [
   { label: 'Previous', emoji: '⬅', style: ButtonStyle.Danger },
   { label: 'Next', emoji: '➡', style: ButtonStyle.Success },
]

new Pagination()
   .setCommand(message)
   .setPages(pages)
   .setButtons(buttons)
   .setPaginationCollector({ timeout: 120000 })
   .setSelectMenu({ enable: true })
   .setFooter({ enable: true })
   .send();

Screenshots

2 Buttons - Previous and Next

Imgur

3 Buttons - Previous, Stop and Next

Imgur

4 Buttons - First, Previous, Next, Last

Imgur

5 Buttons - First, Previous, Stop, Next, Last

Imgur

Documentation

  • For DiscordJS V13/V14:
new Pagination()
   .setCommand(message)
   .setPages(pages)
   .setButtons(buttons)
   .setPaginationCollector({ timeout: 120000 })
   .setSelectMenu({ enable: true })
   .setFooter({ enable: true })
   .setCustomComponents([])
   .setCustomComponentsFunction(fn)
   .send();

Methods

| Name | Optional | Details | | --- | --- | --- | | setCommand(message / interaction) | ❌ | Message or Slash Interaction Accepted | | setPages(pages) | ❌ | Array of MessageEmbeds(DiscordJS V13) or EmbedBuilder(DiscordJS V14) | | send() | ❌ | Executes the pagination | | setButtons([{ parameters }, { parameters }, ...]) | ✔️ | Array of objects containing styles, labels and/or emojis for the buttons | | setPaginationCollector({ parameters }) | ✔️ | Optional Method to set Select Menu Options | | setSelectMenu({ parameters }) | ✔️ | Optional Method to set Collector Options | | setFooter({ parameters }) | ✔️ | Optional Method to set Footer Options | | setCustomComponents({ parameters }) | ✔️ | Optional Method to set Custom Component Options | | setCustomComponentsFunction(fn) | ✔️ | Optional Method to set Custom Component Function |

Optional Methods

setButtons([{ parameters }, { parameters }, ...])

Default: An Empty Array ( [] )

| Parameter | Type | Details | | --- | --- | --- | | label | String | The text to be displayed on this button | | emoji | Emoji | The emoji to be displayed on this button |

setFooter({ parameters })

Defaults:

  • {User Tag} - message.member.user.tag || interaction.member.user.tag
  • {User Avatar} - message.author.displayAvatarURL({ dynamic: true }) || interaction.user.displayAvatarURL({ dynamic: true })

| Parameter | Type | Default | Details | | --- | --- | --- | --- | | option | String | 'default' | 'user' - Uses the User's Embed Footer; 'none' - Remove Embed Footer; 'default': The Package Default Footer with parameters modifications(Below) | | pagePosition | String | 'left' | Adjust the pagePosition to the left, right or none. | | extraText | String | 'Requested by {User Tag}' | The user can customize this text to be displayed on the footer | | enableIconURL | Boolean | true | Set tp false to disable Footer Icon(Image) | | iconURL | String | {User Avatar} | The icon URL of the footer |

setSelectMenu({ parameters })

| Parameter | Type | Default | Details | | --- | --- | --- | --- | | enable | Boolean | false | Set to true to enable Select Menu | | placeholder | String | 'Select Page' | The text to be displayed as placeholder for the Select Menu | | pageOnly | Boolean | false | True: Forced Select Menu Options is page numbers; False: Select Menu Options is the Embed Title(if different), otherwise page numbers |

setPaginationCollector({ parameters })

| Parameter | Type | Default | Details | | --- | --- | --- | --- | | components | String | 'disable' | Options: 'disable' - Disables the components at the end ; 'disappear' - Remove the components at the end | | ephemeral | Boolean | false | Set to true to make the Pagination Collector ephemeral | | resetTimer | Boolean | true | Set to true to reset the Pagination Collector timer | | startingPage | Number | 1 | Set Default Page Number | | secondaryUserInteraction | Boolean | false | Set to true to allow secondary user interaction | | secondaryUserText | String | 'This isn't your interaction.' | The text to be displayed for the secondary user | | timeout | Number | 120000 | The time in milliseconds before the Pagination Collector times out |

setCustomComponents([component, ...])

Default: An Empty Array ( [] )

| Parameter | Type | Details | | --- | --- | --- | | component | ActionRow | Represents an action row component |

setCustomComponentsFunction(fn)

| Parameter | Type | Details | | --- | --- | --- | | fn | Function | Function to handle the custom component |

Example:

const customFn = function fn({ message, msg, pages, collector, setPage, setPages }, interaction) {
   switch(interaction.customId) {
      case 'test':
         setPage(2);
         break;
   }
}

return new Pagination()
   .setCustomComponentsFunction(customFn)
   . ...

Bots that use this package

| Avatar | Name | | --- | --- | | | Toating Bot | | | Savage Bot |