2.3.0 • Published 9 months ago
discord-msg-pagination v2.3.0
Discord Message Pagination
Discord Message Pagination is an addon for Discord.js. It helps you to create paginated messages using slash commands and message components (Buttons) if your content is too long for one message.
Installation
Node.js v16.6.0 or newer is required.
npm install discord-msg-pagination
Optional packages
- discord-embed-colors to easily convert hex colors to decimal numbers used in discord embeds
Usage
Quick start using embed array
import { sendPaginatedEmbed } from 'discord-msg-pagination';
sendPaginatedEmbed(interaction, embeds);
Using a custom function to update message embed dynamically
onPageChange
will be called whenever a button interaction happens.
import { sendPaginatedEmbed } from 'discord-msg-pagination';
function onPageChange(pageNumber, embed) {
return embed
.setTitle(`This is page #${pageNumber}`);
}
sendPaginatedEmbed(interaction, initialEmbed, { onPageChange });
Options
interface Options {
/**
* Text to be displayed on next button
*/
nextLabel?: string,
/**
* Text to be displayed on previous button
*/
previousLabel?: string,
/**
* How long the buttons will work (defaults to 10min)
*/
time?: number,
/**
* Button style
*/
style?: ButtonStyle,
/**
* Function which will run if the page changed. Only if second argument is not an array.
*/
onPageChange?: (event: 'next' | 'previous' | string, embed: EmbedBuilder) => EmbedBuilder | Promise<EmbedBuilder>,
/**
* Message content
*/
content?: string,
/**
* Add custom components to render above the pagination buttons
*/
components?: ActionRowBuilder<any>[],
/**
* Specifiy a restriction for pagination buttons
*/
restriction?: 'ALL' | 'AUTHOR' | ((member: GuildMember) => boolean | Promise<boolean>),
/**
* Set a start index. Default index is 0
*/
startIndex?: number,
/**
* Send ephemeral response
*/
ephemeral?: boolean
}
Local test
Set your DISCORD_BOT_TOKEN
to your .env
.
cp .env.sample .env
npm run test:bot
1.2.0
9 months ago
1.1.1
9 months ago
1.1.0
10 months ago
2.3.0
9 months ago
2.1.2
9 months ago
2.2.0
9 months ago
2.1.1
9 months ago
2.1.0
9 months ago
2.0.1
9 months ago
2.0.0
9 months ago
1.0.13
1 year ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.12
1 year ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.6
2 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.0
3 years ago