Skip to content
acegoal07 edited this page Mar 1, 2024 · 15 revisions

discordjs-pagination

Repository size npm NPM npm (prod) dependency version Libraries.io dependency status for latest release GitHub contributors Monthly Downloads

Pagination functions

.setPortal()
.setPageList()
.setImageList()
.setButtonList()
.setAttachmentList()
.setTimeout()
.setProgressBar()
.enableReplyMessage()
.enableAutoDelete()
.enablePrivateReply()
.enableAuthorIndependent()
.enableAutoButton()
.enableAutoDelButtons()
.paginate()

Example

const { Pagination } = require("@acegoal07/discordjs-pagination");

// Message example
new Pagination().setPortal(message)
   .setPageList([
      new EmbedBuilder()
         .setTitle("Embed 1")
         .setDescription("page 1"),
      new EmbedBuilder()
         .setTitle("Embed 2")
         .setDescription("page 2")
   ])
   .setButtonList([
      new ButtonBuilder()
         .setLabel(`1`)
         .setStyle("Secondary")
         .setCustomId(`1`),
      new ButtonBuilder()
         .setLabel(`2`)
         .setStyle("Secondary")
         .setCustomId(`2`)
   ])
   .paginate()

// Interaction example
new Pagination().setPortal(interaction)
   .setPageList([
      new EmbedBuilder()
         .setTitle("Embed 1")
         .setDescription("page 1"),
      new EmbedBuilder()
         .setTitle("Embed 2")
         .setDescription("page 2")
   ])
   .setButtonList([
      new ButtonBuilder()
         .setLabel(`1`)
         .setStyle("Secondary")
         .setCustomId(`1`),
      new ButtonBuilder()
         .setLabel(`2`)
         .setStyle("Secondary")
         .setCustomId(`2`)
   ])
   .paginate()

// Interaction ephemeral examples
   // way 1 sends a deferred interaction with it enabled
   await interaction.deferReply({ephemeral: true})
   new Pagination().setPortal(interaction)
      .setPageList([ ........

   // way 2 sends an un-deferred interaction which is used to enable it
   new Pagination().setPortal(interaction, {interaction_ephemeral: true}) 
      .setPageList([ ........

// How to use setImageList instead of setPageList
// to use images you just replace the setPageList with
// setImageList
   .setImageList([
       new AttachmentBuilder(url),
       new AttachmentBuilder(path)
   ])
Clone this wiki locally