JSPM

  • Created
  • Published
  • Downloads 74
  • Score
    100M100P100Q83063F
  • License MIT

A simple pagination for Discord.js

Package Exports

  • @acegoal07/discordjs-pagination
  • @acegoal07/discordjs-pagination/index.js
  • @acegoal07/discordjs-pagination/lib/interaction
  • @acegoal07/discordjs-pagination/lib/message

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@acegoal07/discordjs-pagination) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

discordjs-pagination

Repository size npm NPM npm (prod) dependency version Libraries.io dependency status for latest release GitHub contributors

About   |   Example   |   NPM   |   Author


About

1.0.9 contains changes that requires you to update your code to support the new version find the universal example here the change is very simple but makes using the dependency easier

Required dependencies:

  • discord.js version 13.0.1^

To install use:

npm i @acegoal07/discordjs-pagination

When calling the pagination make sure it is pagination({ }) without the brackets it won't work

Example

// Import the @acegoal07/discordjs-pagination package
const pagination = require('@acegoal07/discordjs-pagination');
const { MessageEmbed , MessageButton } = require('discord.js');

// Use MessageEmbed to make pages
// Keep in mind that Embeds should't have their footers set since 
// the pagination method sets page info there
const embed1 = new MessageEmbed()
    .setTitle('First Page')
    .setDescription('This is the first page');

const embed2 = new MessageEmbed()
    .setTitle('Second Page')
    .setDescription('This is the second page');

// Use MessageButton to create the buttons
// Do not used link buttons as they don't give an output
const button1 = new MessageButton()
    .setCustomId('previousbtn')
    .setLabel('Previous')
    .setStyle('DANGER');

const button2 = new MessageButton()
    .setCustomId('nextbtn')
    .setLabel('Next')
    .setStyle('SUCCESS');

// The delete button is optional and is not required for
// pagination to work
const button3 = new MessageButton()
    .serCustomId('delbtn')
    .setLabel('Delete')
    .setStyle('DANGER');

// Create an array of embeds
pages = [
    embed1,
    embed2
    // ... Can add as many embeds as you want
];

//create an array of buttons
buttonList = [
    button1,
    button2,
    button3 // just add the optional delete after the 2 main buttons
]

// Create timeout amount 
const timeout = 3000;
// Timeout is how long the collector will listen to the buttons till
// turing off if you do not include the timeout it defaults to 12000

// Call the pagination, first three arguments are required. make sure that the arguments are 
// within brackets like so ({}) otherwise you'll get an error and it won't work

// For messages use
pagination({message, pages, buttonList, timeout});

// For interaction use
pagination({interaction, pages, buttonList, timeout});