Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suneettipirneni/discord.js-embed-pagination
A paginator utility for Discord.js embeds.
https://github.com/suneettipirneni/discord.js-embed-pagination
discord-js
Last synced: 24 days ago
JSON representation
A paginator utility for Discord.js embeds.
- Host: GitHub
- URL: https://github.com/suneettipirneni/discord.js-embed-pagination
- Owner: suneettipirneni
- License: mit
- Created: 2021-08-14T20:54:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-21T19:30:09.000Z (almost 3 years ago)
- Last Synced: 2024-10-30T13:23:55.460Z (2 months ago)
- Topics: discord-js
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/discord.js-embed-pagination
- Size: 968 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Discord.js Embed Pagination
An easy and highly customizable utility for paginating embeds in discord.js.
## Features
### Out of bounds button checking.
Buttons become disabled when at the beginning or end of page list:
![bounds demo](/docs/bounds.gif)
### Automatic Cleanup
Whenever the given timeout occurs, buttons are automatically removed as well as the current page footer.
## Quick Start
Simply import the and use the utility function:
```ts
import { sendPaginatedEmbeds } from 'discord.js-embed-pagination';sendPaginatedEmbeds(interaction, embeds);
```### Example
```ts
import { sendPaginatedEmbeds } from 'discord.js-embed-pagination';const titles = [
'Page 1',
'Page 2',
'Page 3',
];async run(interaction: CommandInteraction) {
const embeds = new titles.map(title => new MessageEmbed().setTitle(title));
await sendPaginatedEmbeds(interaction, embeds);
}
```## Customization
You can provide options for how the embed is displayed
```ts
interface PageButtonOptions {
/**
* The style of the button.
*/
style?: InteractionButtonOptions['style'];/**
* The text to be displayed on the next button (Defaults to 'Next').
*/
nextLabel?: string;/**
* The text to be displayed on the previous button. (Defaults to 'Previous').
*/
previousLabel?: string;/**
* The message to be alongside the paginated embeds.
*/
content?: string;/**
* Whether or not to show the current page in the footer of each embed (Defaults to being shown).
*/
showPagePosition?: boolean;/**
* How long the paginator should run for in ms. (Default is 30min)
*/
time?: number;/**
* The label that displays in the page position footer.
*/
pageLabel?: string;
}
```Like changing the color and label text for example:
```ts
await sendPaginatedEmbeds(interaction, embeds, {
style: 'SECONDARY',
previousLabel: 'Previous Page!',
nextLabel: 'Next Page!',
});
```This results in something like this: