mudkipscience / discordjs-pagination

A pagination module for Discord.js v13 & Discord.js v14

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub issues GitHub stars GitHub license npm
npm (tag)

โ“ discordjs-pagination

An advanced module with quick setup and different options to implement pagination system for Discord.js.
The 2... versions of the package will only support discord.js v14.


If you want this package for discord.js v13, please install v1.8...

๐Ÿ“ฅ Installation

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

npm i @devraelfreeze/discordjs-pagination

โš™๏ธ Pagination Module Options

Options Object Name Default Type Description
interaction CommandInteraction
or Interaction
Interaction to reply with the pagination system
(The interaction can be deferred or replied)
message Message Message Class to send the pagination system
ephemeral boolean If the returned message should be ephemeral (Can only use in Interaction)
embeds [] 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
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, TypesButtons, StylesButton } = 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: [
        {
            value: TypesButtons.previous,
            label: 'Previous Page',
            style: StylesButton.Primary
        },
        {
            value: TypesButtons.next,
            label: 'Next Page',
            style: StylesButton.Success
        }
    ]
});

Use pagination System with custom buttons and custom filter

await pagination({
    interaction: interaction,
    embeds: arrayEmbeds, // Array of embeds objects
    author: interaction.member.user,
    time: 40000, // 40 seconds
    fastSkip: false,
    disableButtons: true,
    pageTravel: false,
    /** Enable buttons pagination system only for member with ID: 123456789 */
    customFilter: (interaction) => {
        return interaction.member.user.id === '123456789';
    },
    buttons: [
        {
            value: TypesButtons.previous,
            label: 'Previous Page',
            style: StylesButton.Success,
            emoji: 'โ—€๏ธ'
        },
        {
            value: TypesButtons.next,
            label: 'Next Page',
            style: StylesButton.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 on Discord: devRael#0123

๐Ÿ—ƒ๏ธ Old Versions

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

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

๐Ÿ“ 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.

About

A pagination module for Discord.js v13 & Discord.js v14

License:MIT License


Languages

Language:TypeScript 100.0%