Giter Club home page Giter Club logo

discordjs-pagination's Introduction

discordjs-pagination

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

About   |   Example   |   Wrapper functions   |   Optional settings help   |   Page and button builder   |   NPM   |   Author


About

This pagination supports both Message and Interaction and automaticity switches between which interface is provided, It also adjusts multiple things about the pagination depending on the data that's provided making it very customisable and user friendly

To download the package use:

For discord version 14.0.0 and higher

npm i @acegoal07/discordjs-pagination

For discord version 13.9.0 and bellow

npm i @acegoal07/[email protected]

If your interested in supporting my projects you can find donation options here

Addition info

The interaction pagination supports deferred interactions but you do not need to defer the interaction yourself as the pagination does it automatically if it is not deferred

All wrapper functions

.setInterface()
.setPageList()
.setButtonList()
.setTimeout()
.setProgressBar()
.enableReplyMessage()
.enableAutoDelete()
.enablePrivateReply()
.enableAuthorIndependent()
.enableAutoButton()
.enableAutoDelButtons()
.createPages()
.createButtons()
.paginate()

Example

const { EmbedBuilder, ButtonBuilder } = require('discord.js');
const pagination = require('@acegoal07/discordjs-pagination');

// Message example
new pagination().setInterface(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().setInterface(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 deferReply({ephemeral: true})
   new pagination().setInterface(interaction)
      .setPageList([ ........

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

Optional settings help

Just add these methods before the paginate function to enable the addons e.g.

new pagination().setInterface(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`)
   ])
   .enableAutoDelete() // <---- Make sure its before the paginate function or it wont enable
   .paginate()

All the available settings and the input they need

.setTimeout(timeInMilliseconds) // Allows you to set a custom timeOut for your pagination
.enableAuthorIndependent() // Enables authorIndependent for your pagination
.enableAutoDelete() // Enables autoDelete for your pagination
.enablePrivateReply() // Enables privateReply for your pagination
.enableReplyMessage() // Enables replyMessage for your pagination
.setProgressBar({newSliderIcon, newBarIcon}) // Enables ProgressBar for your pagination and also allows you to edit the characters
.enableAutoButton(deleteButton) // Enables autoButton for your pagination
.enableSelectMenu({useTitle, labels}) // Enables selectMenu for your pagination and allows you to set custom labels for the selectMenu items
.createPages() // View create help to see how to use this feature
.createButtons() // View create help to see how to use this feature

Create help

Create Pages example

// This feature replaces the .setPageList() function
.createPages([
   {
      color: "Red",
      title: "page1",
      url: "https://acegoal07.dev",
      description: "page1 is here",
      author: {
         name: "acegoal07",
         icon_url: "https://acegoal07.dev/Resources/Pictures/acegoal07.webP",
         url: "https://acegoal07.dev",
      },
      thumbnailUrl: "https://acegoal07.dev/Resources/Pictures/acegoal07.webP",
      fields: [
         {
            name: "Look i work",
            value: "Hello World!",
            inline: false,
         },
         {
            // And carry on like so
         }
      ],
      imageUrl: "https://acegoal07.dev/Resources/Pictures/acegoal07.webP",
   },
   {
      // And carry on like so
   }
])

create Buttons example

// This feature replaces the .setButtonList() function
.createButtons([
   {
      customId: "button1",
      label: "i am button 1",
      emoji: "123456789012345678", // emoji replaces the label
      style: "Success"
   },
   {
      // And carry on like so
   }
])

discordjs-pagination's People

Contributors

acegoal07 avatar notghex 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.