GithubHelp home page GithubHelp logo

thevalleyy / discordjs-button-pagination Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ryzyx/discordjs-button-pagination

0.0 0.0 0.0 96 KB

>> A simple package for pagination using buttons introduced in discord.js v14.

Home Page: https://www.npmjs.com/package/discordjs-button-pagination

License: MIT License

JavaScript 100.00%

discordjs-button-pagination's Introduction

This repo ist archived since the message content access was removed.

discordjs-pagination

NPM info

discordjs-button-pagination

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

Versions

discordjs-button-pagination@interaction [Default]

for slash command interaction.

discordjs-button-pagination@msg

for message command.

Installation

For message event

  • npm install discordjs-button-pagination@msg

For interaction event

  • npm install discordjs-button-pagination@interaction

Default command: npm install discordjs-button-pagination will install the interaction version

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');

// 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 { MessageEmbed , MessageButton} = require('discord.js');
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');

const button1 = new MessageButton()
                .setCustomId('previousbtn')
                .setLabel('Previous')
                .setStyle('DANGER');

const button2 = new MessageButton()
                .setCustomId('nextbtn')
                .setLabel('Next')
                .setStyle('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.

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

discordjs-button-pagination's People

Contributors

2jjj avatar d-shaun avatar dotnize avatar jkl2k2 avatar kkjustkk7074 avatar ryzyx avatar sudhanplayz avatar thevalleyy avatar thoughts3rased avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.