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

@devraelfreeze/discordjs-pagination

v2.7.6

Published

A pagination module for Discord.js v14

Downloads

2,117

Readme

❓discordjs-pagination

An advanced module with quick setup and different options to implement pagination system for Discord.js. This package only support discord.js v14.

I will not do any more updates for version 1.8.x.

This package is no longer compatible with discord.js v13

📥 Installation

To install this module type the following command in your console:

npm install @devraelfreeze/discordjs-pagination

⚙️ Pagination Module Options

| Options Object Name | Default Type | Description | |:--------------------|:----------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------| | client | Client | Bot client, only useful if time >= 900000 (i.e greater than 15 minutes) | | interaction | MessageComponentInteraction orCommandInteraction | Interaction to reply with the pagination system (The interaction can be deferred or replied) | | message | Message | Message Object to send the pagination system | | ephemeral | boolean | If the returned message should be ephemeral (Can only use in Interaction) | | embeds | Embed[] | Array of embeds to paginate | | author | User | Author's user class | | buttons | Buttons[] | Customization of your buttons See examples below | | disableButtons | boolean | Disable or remove buttons after timeout (true = disable, false = remove) | | deleteAtEnd | boolean | Delete or not the embed or message after timeout (true = remove, false = keep) | | pageTravel | boolean | Travel pages by sending page numbers (With Modal Interaction) | | fastSkip | boolean | Create two additional buttons, a button to skip to the end and a button to skip to the first page | | time | number | How long before pagination get disabled (in ms) | | max | number | Maximum interactions with buttons before disabling the pagination | | customFilter | boolean | Custom filter for message component collector Must return boolean |

⬇️ Examples

Declare & Use Pagination System

/** Decalre the module */
const {pagination, ButtonTypes, ButtonStyles} = require('@devraelfreeze/discordjs-pagination');
/** Use pagination system */
await pagination({
  /** Pagination options here */
});

Use pagination System with custom buttons

await pagination({
  embeds: arrayEmbeds, /** Array of embeds objects */
  author: interaction.member.user,
  interaction: interaction,
  ephemeral: true,
  time: 40000, /** 40 seconds */
  disableButtons: false, /** Remove buttons after timeout */
  fastSkip: false,
  pageTravel: false,
  buttons: [
    {
      type: ButtonTypes.previous,
      label: 'Previous Page',
      style: ButtonStyles.Primary
    },
    {
      type: ButtonTypes.next,
      label: 'Next Page',
      style: ButtonStyles.Success
    }
  ]
});

Use pagination System with custom buttons and custom filter

await pagination({
  interaction: interaction,
  embeds: arrayEmbeds,
  author: interaction.member.user,
  time: 40000,
  fastSkip: false,
  disableButtons: true,
  pageTravel: false,
  /** Enable buttons pagination system only for member with ID: 123456789 */
  customFilter: (interaction: CommandInteraction|MessageComponentInteraction) => {
    return interaction.member.user.id === '123456789';
  },
  buttons: [
    {
      type: ButtonTypes.previous,
      label: 'Previous Page',
      style: ButtonStyles.Success,
      emoji: '◀️'
    },
    {
      type: ButtonTypes.next,
      label: 'Next Page',
      style: ButtonStyles.Success,
      emoji: null /** Disable emoji for this button */
    }
  ]
});

🐛 Bug Reports

If you have any bugs or trouble setting the module up, feel free to open an issue on GitHub Repository

If you want more support, you can contact me.

Discord: 1043813027205619804

🗃️ Old Versions

If you want to use old version, you can use command

npm install @devraelfreeze/discordjs-pagination@<version>

🧾 TODO

  • Create new customComponents parameter to let the user choose to add buttons / selections menus in the components of the pagination system.
  • Create new Screenshots section in README and show examples
  • Make the package compatible so that it takes into account an array of Message objects and not only an array of Embed objects.

📝 License

Copyright © 2022 devRael1 This project is MIT licensed. This is not an official Discord product. It is not affiliated with or endorsed by Discord Inc.