2.1.1 • Published 9 months ago

customizable-discordjs-pagination v2.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

customizable-discordjs-pagination

Install package

npm install customizable-discordjs-pagination

Discord.js v13 Example

const Pagination = require('customizable-discordjs-pagination');

// Make Embeds using DiscordJS package
const pages = [embed1, embed2, embed3];

const buttons = [
   { label: 'Previous', emoji: '⬅', style: 'DANGER' },
   { label: 'Next', emoji: '➡', style: 'SUCCESS' }
];

new Pagination()
   .setCommand(message)
   .setPages(pages)
   .setButtons(buttons)
   .setPaginationCollector({ timeout: 120000 })
   .setSelectMenu({ enable: true })
   .setFooter({ enable: true })
   .send();

Discord.js v14 Example

const Pagination = require('customizable-discordjs-pagination');
const { ButtonStyle } = require('discord.js'); // Discord.js v14+

// Make Embeds using DiscordJS package
const pages = [embed1, embed2, embed3];

const buttons = [
   { label: 'Previous', emoji: '⬅', style: ButtonStyle.Danger },
   { label: 'Next', emoji: '➡', style: ButtonStyle.Success },
]

new Pagination()
   .setCommand(message)
   .setPages(pages)
   .setButtons(buttons)
   .setPaginationCollector({ timeout: 120000 })
   .setSelectMenu({ enable: true })
   .setFooter({ enable: true })
   .send();

Screenshots

2 Buttons - Previous and Next

Imgur

3 Buttons - Previous, Stop and Next

Imgur

4 Buttons - First, Previous, Next, Last

Imgur

5 Buttons - First, Previous, Stop, Next, Last

Imgur

Documentation

  • For DiscordJS V13/V14:
new Pagination()
   .setCommand(message)
   .setPages(pages)
   .setButtons(buttons)
   .setPaginationCollector({ timeout: 120000 })
   .setSelectMenu({ enable: true })
   .setFooter({ enable: true })
   .setCustomComponents([])
   .setCustomComponentsFunction(fn)
   .send();

Methods

NameOptionalDetails
setCommand(message / interaction)Message or Slash Interaction Accepted
setPages(pages)Array of MessageEmbeds(DiscordJS V13) or EmbedBuilder(DiscordJS V14)
send()Executes the pagination
setButtons({ parameters }, { parameters }, ...)✔️Array of objects containing styles, labels and/or emojis for the buttons
setPaginationCollector({ parameters })✔️Optional Method to set Select Menu Options
setSelectMenu({ parameters })✔️Optional Method to set Collector Options
setFooter({ parameters })✔️Optional Method to set Footer Options
setCustomComponents({ parameters })✔️Optional Method to set Custom Component Options
setCustomComponentsFunction(fn)✔️Optional Method to set Custom Component Function

Optional Methods

setButtons({ parameters }, { parameters }, ...)

Default: An Empty Array ( [] )

ParameterTypeDetails
labelStringThe text to be displayed on this button
emojiEmojiThe emoji to be displayed on this button

setFooter({ parameters })

Defaults:

  • {User Tag} - message.member.user.tag || interaction.member.user.tag
  • {User Avatar} - message.author.displayAvatarURL({ dynamic: true }) || interaction.user.displayAvatarURL({ dynamic: true })
ParameterTypeDefaultDetails
optionString'default''user' - Uses the User's Embed Footer; 'none' - Remove Embed Footer; 'default': The Package Default Footer with parameters modifications(Below)
pagePositionString'left'Adjust the pagePosition to the left, right or none.
extraTextString'Requested by {User Tag}'The user can customize this text to be displayed on the footer
enableIconURLBooleantrueSet tp false to disable Footer Icon(Image)
iconURLString{User Avatar}The icon URL of the footer

setSelectMenu({ parameters })

ParameterTypeDefaultDetails
enableBooleanfalseSet to true to enable Select Menu
placeholderString'Select Page'The text to be displayed as placeholder for the Select Menu
pageOnlyBooleanfalseTrue: Forced Select Menu Options is page numbers; False: Select Menu Options is the Embed Title(if different), otherwise page numbers

setPaginationCollector({ parameters })

ParameterTypeDefaultDetails
componentsString'disable'Options: 'disable' - Disables the components at the end ; 'disappear' - Remove the components at the end
ephemeralBooleanfalseSet to true to make the Pagination Collector ephemeral
resetTimerBooleantrueSet to true to reset the Pagination Collector timer
startingPageNumber1Set Default Page Number
secondaryUserInteractionBooleanfalseSet to true to allow secondary user interaction
secondaryUserTextString'This isn\'t your interaction.'The text to be displayed for the secondary user
timeoutNumber120000The time in milliseconds before the Pagination Collector times out

setCustomComponents(component, ...)

Default: An Empty Array ( [] )

ParameterTypeDetails
componentActionRowRepresents an action row component

setCustomComponentsFunction(fn)

ParameterTypeDetails
fnFunctionFunction to handle the custom component

Example:

const customFn = function fn({ message, msg, pages, collector, setPage, setPages }, interaction) {
   switch(interaction.customId) {
      case 'test':
         setPage(2);
         break;
   }
}

return new Pagination()
   .setCustomComponentsFunction(customFn)
   . ...

Bots that use this package

AvatarName
npm.ioToating Bot
npm.ioSavage Bot
2.1.1

9 months ago

2.1.0

10 months ago

2.0.3

1 year ago

2.0.2

1 year ago

1.2.0

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.3.1

2 years ago

1.1.3

2 years ago

1.3.0

2 years ago

1.1.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago