2.1.5 ā€¢ Published 2 years ago

@koenie06/discord.js-pagination v2.1.5

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

ā„¹ļø About

Easily create your own Discord.js embed paginator with buttons/emoji's, it is also fully customizable! Do you need help? Contact the owner at Discord! Koenie06#9999

šŸ“„ Installation

Wait! Before you install, you need..

  • Node.js v14+

  • Discord.js v13+

After this, you can finally install the package with:

$ npm install @koenie06/discord.js-pagination

šŸ“œ Usage

šŸ–±ļø Buttons

/* Import all the general stuff, you can't do anything without it.. */
const { Client, Intents, MessageEmbed } = require('discord.js');
const paginator = require('@koenie06/discord.js-pagination');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'help') {

            /*
             * The function requires atleast 2 items:
             * 1) Interaction. This is used to start the paginator.
             * 2) Pages. A array of all the pages (MessageEmbed's).
             * 
             * There are also some optional items:
             * 1) Buttons. A Object with button information to customize the buttons.
             * 2) Timeout. A Integer of the time when the paginator stops.
            */

            const page1 = new MessageEmbed().setTitle('This is page 1')
            const page2 = new MessageEmbed().setTitle('This is page 2')
            const page3 = new MessageEmbed().setTitle('This is page 3')

            paginator.button({
                interaction: interaction,
                pages: [page1, page2, page3],
                buttons: {
                    previous: {
                       label: 'Click for previous page',
                       style: 'SUCCES',
                       emoji: '12345678910'
                    },
                    next: {
                        label: 'Click for next page',
                        style: 'SUCCES',
                        emoji: '12345678910'
                    },
                    stop: {
                        label: 'Click to stop',
                        style: 'DANGER',
                        emoji: '12345678910'
                    }
                },
                timeout: 30000
            });

        };
    };
});

client.login('Client token from https://discord.com/developers/applications')

šŸ˜€ Reactions

/* Import all the general stuff, you can't do anything without it.. */
const { Client, Intents, MessageEmbed } = require('discord.js');
const paginator = require('@koenie06/discord.js-pagination');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'help') {

            /*
             * The function requires atleast 2 items:
             * 1) Interaction. This is used to start the paginator.
             * 2) Pages. A array of all the pages (MessageEmbed's).
             * 
             * There are also some optional items:
             * 1) Emoji's. A Object with emoji information to customize the emoji's.
             * 2) Timeout. A Integer of the time when the paginator stops.
            */

            const page1 = new MessageEmbed().setTitle('This is page 1')
            const page2 = new MessageEmbed().setTitle('This is page 2')
            const page3 = new MessageEmbed().setTitle('This is page 3')

            paginator.emoji({
                interaction: interaction,
                pages: [page1, page2, page3],
                emojis: {
                    previous: '12345678910',
                    next: '12345678910',
                    stop: '12345678910'
                },
                timeout: 30000
            });

        };
    };
});

client.login('Client token from https://discord.com/developers/applications')

šŸ“ƒ Menus

/* Import all the general stuff, you can't do anything without it.. */
const { Client, Intents, MessageEmbed } = require('discord.js');
const paginator = require('@koenie06/discord.js-pagination');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS] });

/* This code will run when the client receives a interaction */
client.on('interactionCreate', async (interaction) => {
    if(interaction.isCommand()) {
        if(interaction.commandName === 'help') {

            /*
             * The function requires atleast 2 items:
             * 1) Interaction. This is used to start the paginator.
             * 2) Pages. A array of all the pages (MessageEmbed's).
             * 
             * There are also some optional items:
             * 1) PlaceHolder. A string with the name of the placeholder.
             * 2) Timeout. A Integer of the time when the paginator stops.
            */

            const page1 = new MessageEmbed().setTitle('This is page 1')
            const page2 = new MessageEmbed().setTitle('This is page 2')
            const page3 = new MessageEmbed().setTitle('This is page 3')

            paginator.menu({
                interaction: interaction,
                menus: {
                    pages: [{
                        embed: page1,
                        value: 'Page 1',
                        label: 'Page 1',
                        description: 'Click here to select the first page'
                    },
                    {
                        embed: page2,
                        value: 'Page 2',
                        label: 'Page 2',
                        description: 'Click here to select the second page'
                    },
                    {
                        embed: page3,
                        value: 'Page 3',
                        label: 'Page 3',
                        description: 'Click here to select the third page'
                    }],
                    placeHolder: 'Click here to select a page!'
                },
                timeout: 30000
            });

        };
    };
});

client.login('Client token from https://discord.com/developers/applications')

šŸ“ˆ Parameters

šŸ–±ļø Buttons / šŸ˜€ Emoji's

ParameterDescriptionTypeRequired
interactionThe interaction you've received from the interactionCreate event.Interactiontrue
pagesA array with all the MessageEmbed'sArraytrue
buttons / emojisA object with the buttons / emojis options in itObjectfalse
timeoutThe time is milliseconds until the collector stopsIntegerfalse

šŸ“ƒ Menu's

ParameterDescriptionTypeRequired
interactionThe interaction you've received from the interactionCreate event.Interactiontrue
menusA object with the menu options in itObjecttrue
timeoutThe time is milliseconds until the collector stopsIntegerfalse

šŸ–±ļø Buttons

ParameterDescriptionContent
previousThe 'previous page' buttonlabel: Stringstyle: MessageButtonStyleResolvableEmoji: Snowflake
nextThe 'next page' buttonlabel: Stringstyle: MessageButtonStyleResolvableEmoji: Snowflake
stopThe 'stop' buttonlabel: Stringstyle: MessageButtonStyleResolvableEmoji: Snowflake

šŸ˜€ Emoji's

ParameterDescriptionType
previousThe 'ā—€' reactionSnowflake
nextThe 'ā–¶' reactionSnowflake
stopThe 'ā›”' reactionSnowflake

šŸ“ƒ Menu's

ParameterDescriptionTypeRequired
pagesA array with objects with the MenuPage options in itArraytrue
placeHolderA string with the name of the placeholderStringfalse
ParameterDescriptionTypeRequired
valueThe custom value of the pageStringtrue
embedThe MessageEmbed itselfMessageEmbedtrue
labelThe name of the pageStringtrue
descriptionThe description of the pageStringfalse
emojiThe custom emoji of the pageSnowflakefalse

ā¤ Credits

  • RaZegame (RaZe#2841) for adding TS support.
  • Iliannnn (Ilian#6635) for finetuning the README.

  • Koenie06 (Koenie06#9999) for making the package. šŸ¤«