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

discordjs-button-pagination-v2

v4.0.2

Published

A simple package for pagination using buttons introduced in discord.js v13 that was updates to work with discord.js v14.

Downloads

11

Readme

discordjs-pagination

discordjs-button-pagination-v2

A simple package to paginate discord embeds via discord buttons introduced in discord.js v13.

Versions

discordjs-button-pagination-v2@interaction [Default]

for slash command interaction.

Installation

Default command: npm install discordjs-button-pagination-v2

Requirements

Node.js 16.6.1 or newer is required along with Discord.js 13.0.0 or newer.

Usage for Interaction (Slash Command)

Basic Bot Example

// Import the discordjs-button-pagination package
const paginationEmbed = require('discordjs-button-pagination-v2');

// 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 { EmbedBuilder , ButtonBuilder, ButtonStyle} = require('discord.js');
const embed1 = new EmbedBuilder()
                .setTitle('First Page')
                .setDescription('This is the first page');

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

const button1 = new ButtonBuilder()
                .setCustomId('previousbtn')
                .setLabel('Previous')
                .setStyle(ButtonStyle.Danger);

const button2 = new ButtonBuilder()
                .setCustomId('nextbtn')
                .setLabel('Next')
                .setStyle(ButtonStyle.Success);

// Create an array of embeds
pages = [
	embed1,
	embed2,
	//....
	//embedN
];

//create an array of buttons

buttonList = [
    button1,
    button2
]


// Call the paginationEmbed method, first three arguments are required
// timeout is the time till the reaction collectors are active, after this you can't change pages (in ms), defaults to 120000
paginationEmbed(interaction, pages, buttonList, timeout);
// There you go, now you have paged embeds

Note

This will not work with buttons whose style is set as 'LINK' as they do not trigger an interaction event. The buttons will auto disable once the the collector ends after the timeout. You must use the following custom ids for it to work. "previousbtn" and "nextbtn"

The collector timer resets after receiving a button interaction.

Preview

First Page

pic1

Second Page

pic2

Disabled Buttons after collector end

pic3

For any issues or suggestions, kindly open an issue/pull request on the GitHub Repository