1.0.2 • Published 4 years ago

embed-pages v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

embed-pages

Package to create and navigate among embed pages using reactions. Works with <MessageEmbeds> (discord.js v12) - might not work with <RichEmbeds>

Installation

npm install embed-pages
# OR
yarn add embed-pages

Example

// get the messsage embed
const { MessageEmbed } = require('discord.js');
// get the embed-pages module
const EmbedPages = require('embed-pages');

// inside your run function..
async run(message, args) {

        // $optional, declare embed(s)
		let embedR = new MessageEmbed(), embedG = new MessageEmbed, embedB = new MessageEmbed();

        // create an array of embeds 
		const pages = [
			embedR, 
			embedG, 
			embedB
		];

        // define your embeds (simple color embeds)
		embedR.setColor('RED').setTitle('RED EMBED');
		embedG.setColor('GREEN').setTitle('GREEN EMBED');
		embedB.setColor('BLUE').setTitle('BLUE EMBED');

        // define embedpages with the properties, pages & channel are required.        
		const embedPages = new EmbedPages({
			pages: pages,
			channel: message.channel,
			duration: 1000 * 30,
			options: user => user.id === message.author.id,
            pageCounter: true
		});

        //create the embed pages and send it.
		embedPages.createPages();

	}

Properties

PropertyTypeInfo, ($) marked are required.
pagesArray\Array of embeds for the embed pages. ($)
channel\Channel where the embed(s) are sent. ($)
durationNumberTime for which the reactions will work defaults to (1000 * 60ms)
optionsArray\FunctionLimit how reactions work by using functions & methods
pageCounterBooleanShows the currentPage/totalPages in the footer, default is false.

Methods

MethodParametersInfo
createPages()NAcreates embed listens to reactions
nextPage()NAedits the embed to the following embed, switches to next embed
previousPage()NAedits the embed to previous embed, switch to previous embed
insertPage()embedadds/inserts a page in the embed-array (needs an embed)
removePage()pageNumremoves a page from the embed-array (specify page number)
flipToPage()pageNumflips to a specified page
delete()NAdeletes the entire embed-pagination
endEmbed()NAends the embed by removing the reactions, runs when collector ends (timeout/user-reaction)

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago