2.7.6 • Published 11 months ago

@devraelfreeze/discordjs-pagination v2.7.6

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

❓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 NameDefault TypeDescription
clientClientBot client, only useful if time >= 900000 (i.e greater than 15 minutes)
interactionMessageComponentInteraction orCommandInteractionInteraction to reply with the pagination system (The interaction can be deferred or replied)
messageMessageMessage Object to send the pagination system
ephemeralbooleanIf the returned message should be ephemeral (Can only use in Interaction)
embedsEmbed[]Array of embeds to paginate
authorUserAuthor's user class
buttonsButtons[]Customization of your buttons See examples below
disableButtonsbooleanDisable or remove buttons after timeout (true = disable, false = remove)
deleteAtEndbooleanDelete or not the embed or message after timeout (true = remove, false = keep)
pageTravelbooleanTravel pages by sending page numbers (With Modal Interaction)
fastSkipbooleanCreate two additional buttons, a button to skip to the end and a button to skip to the first page
timenumberHow long before pagination get disabled (in ms)
maxnumberMaximum interactions with buttons before disabling the pagination
customFilterbooleanCustom 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.

2.7.4

1 year ago

2.7.6

11 months ago

2.7.5

11 months ago

2.7.0

1 year ago

2.7.2

1 year ago

2.6.6

1 year ago

2.6.8

1 year ago

2.6.4

2 years ago

1.8.8

2 years ago

1.8.6

2 years ago

2.6.0

2 years ago

2.6.2

2 years ago

2.5.0

2 years ago

1.8.4

2 years ago

2.4.2

2 years ago

1.8.2

2 years ago

2.4.0

2 years ago

2.2.0

2 years ago

2.0.0

2 years ago

1.8.0

2 years ago

1.6.0

2 years ago

1.4.0

2 years ago