1.1.1 • Published 2 years ago

dispage v1.1.1

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

About

dispage is a powerful Node.js module that allows you to easily create button to switch over embed pages on a discord message.

Dependencies

Needs discord.js v14.6.0 or higher. If discord.js isn't installed yet :

npm install discord.js@latest

Installation

npm i dispage

Importing

Javascript

const Dispage = require('dispage')

Typescript

import Dispage from 'dispage';

Simple example

const embeds = [
    new MessageEmbed().setDescription('Embed #1'),
    new MessageEmbed().setDescription('Embed #2')
];
return new Dispage()
    .setEmbeds(embeds)
    .start(message)

Simple example

If you want to push things further...

const embeds = [
    'embed 1',
    'embed 2 !!',
    'embed 3 !?!',
    'embed 4 !!!!!!!!?'
].map((desc, i) => new Discord.EmbedBuilder()
    .setTitle(`📃 Page #${i + 1}`)
    .setColor('BLURPLE')
    .setDescription(desc))

new Dispage()
    .setEmbeds(embeds)
    // This style will be given to every button that doesn't have a specific style
    .setMainStyle('Secondary')
    .editButton('previous', { emoji: "824240081409540157", label: "Previous" })
    // Setting a property (here, style) to null will remove it. 👇
    .editButton('stop', { emoji: "961338862259544114", label: null })
    .editButton('next', { emoji: "824240024509874186", label: "Next" })
    // We can edit as many buttons as we want and as many times as we wish
    .editButton('stop', { style : "Success" })
    // You can create your own custom button
    .addButton({
        label: "Go to Message",
        style: "Link",
        url: "https://discord.com/channels/937626764916719626/937633296878293002/978956060972974101"
    })
    // Finally after having setup everything. We can start
    .start(message)

Page 1 Page 2

Properties

Instead of (for example) setting index to 1 by hand. Use the build-in (setIndex) method. Same for embeds (.setEmbeds), ended (.end()), duration (.setDuration) etc..

PropertyTypeDefault Value
clientClientnull
indexnumber0
embedsEmbed[][]
messageMessagenull
interactionInteractionnull
collectorInteractionCollector<ButtonInteraction>null
replyMessagenull
endedbooleanfalse
startedbooleanfalse
deletedbooleanfalse
durationnumber60000
mainStyleMessageButtonStyle"PRIMARY"
buttonsMessageButtonOptions[]MessageButtonOptions[]

Methods

On the Return column, this means that the methode returns the original instance of the class. Like discord.js's MessageEmbed where we can call multiple times multiple methods following themselves. Like this: new Dispage().setMainStyle('SECONDARY').setIndex(2) etc..

PS: ⚠ MEANS DEPRECATED (Meaning you shouldn't use it anymore)

NameArgumentsReturn
setMainStyleMessageButtonStylethis
showDisabledButtonsbooleanthis
removeUserUserthis
addUserUserthis
setUserUserthis
addButtonMessageButtonOptionsthis
removeButtonstringthis
editButtonstring, MessageButtonOptionsthis
getRowsbooleanMessageActionRow[]
setEmbedsEmbed[]this
addEmbedEmbedthis
addEmbedsEmbed[]this
_fixEmbedsEmbed[] / Embed / Embed[][]Embed[]
setDurationnumberthis
addDurationnumberthis
nextPromise<this>
previousPromise<this>
changeToPagenumberPromise<Message>
doesIndexExistnumberboolean
setIndexNumberthis
editMessageEditOptionsPromise<Discord.Message>
disableButtonsvoid
endvoid
deletevoid
updatevoid
getOptsBooleanMessageOptions
isMessageboolean
isInteractionboolean
canEditboolean
isValidCtxContextboolean
checkForErrorsContextstring[]
startContextPromise<this>

Trouble

Having a problem using dispage ? Open an issue on Github & Don't hesitate to send a message to the discord tag below 👇 !

Credits

Made by voxlinou1 (Vox#6198 on discord)

1.1.1

2 years ago

1.1.0

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

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