1.0.1 • Published 2 years ago

@eugabrielsilva/djs-paginate v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

djs-paginate

Simpler discord.js v13 embed pagination tool inspired by discordjs-button-pagination.

Installation

npm install @eugabrielsilva/djs-paginate

Usage

// Import the module
const paginate = require('@eugabrielsilva/djs-paginate');

// Create your embed pages
const { MessageEmbed } = require('discord.js');

let page1 = new MessageEmbed({
    title: 'Page 1',
    description: 'This is the first page'
});

let page2 = new MessageEmbed({
    title: 'Page 2',
    description: 'This is the second page'
});

// Create an array with your pages
let pages = [page1, page2];

// Call the paginate() method passing the message object (from client messageCreate event) and the pages array
paginate(message, pages);

Options

The third argument to the paginate() function is an object with one or more of the following parameters:

ParameterDescriptionTypeDefault
timeoutTime (in seconds) to disable the paginator collector after no interactions are received.int60
prevTextText to show in the previous button.string"⏪ Anterior"
nextTextText to show in the next button.string"Próxima ⏩"
pageTextText to show before the page counter.string"📄 Página"
pageSeparatorText to show between the page counter.string"/"

Example:

paginate(message, pages, {
    timeout: 120,
    prevText: 'Previous',
    nextText: 'Next',
    pageText: 'Page',
    separatorText: 'from'
});

Credits

Library developed and currently maintained by Gabriel Silva.\ Special thanks to ryzyx for the original idea.