# @falloutstudios/djs-pagination

> Discord.js v14 button and reaction pagination

Latest version **2.0.5** (published 2024-01-24) · GPL-3.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @falloutstudios/djs-pagination
pnpm add @falloutstudios/djs-pagination
yarn add @falloutstudios/djs-pagination
bun add @falloutstudios/djs-pagination
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.5 |
| Published | 2024-01-24 |
| First published | 2022-10-31 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 110.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | catplusplus |
| Keywords | djs, discord.js, pagination, reaction, button |

## Links

- npm: https://www.npmjs.com/package/@falloutstudios/djs-pagination
- Repository: https://github.com/FalloutStudios/djs
- Homepage: https://falloutstudios.github.io/djs/modules/_falloutstudios_djs_pagination.html
- Issues: https://github.com/FalloutStudios/djs/issues
- npm.io page: https://npm.io/package/@falloutstudios/djs-pagination

## Dependencies (1)

- [fallout-utility](https://npm.io/package/fallout-utility.md) ^2.8.0

## Recent versions

- 2.0.5 (latest) — 2024-01-24
- 2.0.4 — 2023-10-10
- 2.0.3 — 2023-09-18
- 2.0.2 — 2023-05-06
- 2.0.1 — 2023-04-19
- 2.0.0 — 2023-04-19
- 1.2.8 — 2023-04-02
- 1.2.7 — 2023-03-05
- 1.2.6 — 2023-02-04
- 1.2.5 — 2023-02-04
- 1.2.4 — 2023-02-03
- 1.2.3 — 2023-01-03
- 1.2.2 — 2023-01-03
- 1.2.1 — 2022-12-16
- 1.1.2 — 2022-12-08
- … 8 more at https://npm.io/package/@falloutstudios/djs-pagination/versions

## README

# Djs Pagination
![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@falloutstudios/djs-pagination?style=flat-square)
![GitHub](https://img.shields.io/github/license/FalloutStudios/djs-pagination?style=flat-square)
![npm (scoped)](https://img.shields.io/npm/v/@falloutstudios/djs-pagination?label=Latest%20Version&style=flat-square)

A simple button and reaction pagination library for Discord.js v14

## Installation

```bash
npm i @falloutstudios/djs-pagination discord.js
```

> See also [Oceanic Pagination](https://www.npmjs.com/package/oceanic-pagination)

### Features
- Object Oriented
- Easy to use
- Uses Message data as pages instead of embeds
  - Supports dynamic pages
  - Allows pages with just message content
  - Supports multiple embeds in one page
  - Custom page action rows
- Supports interaction followUps
- Highly customizable
- Typescript support

## Getting Started

> You can use this in TypeScript, ESM, or CommonJS but in these examples we're gonna use CommonJS.

### Button Pagination

```js
const { ButtonPaginationBuilder } = require('@falloutstudios/djs-pagination');
const { ButtonBuilder, Client, EmbedBuilder } = require('discord.js');

const bot = new Client({
    intents: ['Guilds', 'MessageContent']
});

bot.on('interactionCreate', async interaction => {
    if (interaction.isChatInputCommand() && interaction.commandName == 'pagination') {
        // Create pagination
        const pagination = new ButtonPaginationBuilder()
            // Add at least one page
            .addPages(
                new EmbedBuilder().setDescription('Page 1'), // Single embed page
                { content: 'Page 2', embeds: [{ title: 'Page 2' }] }, // Message data embed
                'Page 3', // String page
                () => new EmbedBuilder().setDescription('Page 4\n' + new Date().toString()) // Dynamic page
            )
            // All buttons are optional
            .addButton(new ButtonBuilder().setLabel('First').setCustomId('first'), 'FirstPage')
            .addButton(new ButtonBuilder().setLabel('Previous').setCustomId('prev'), 'PreviousPage')
            .addButton(new ButtonBuilder().setLabel('Stop').setCustomId('stop'), 'Stop')
            .addButton(new ButtonBuilder().setLabel('Next').setCustomId('next'), 'NextPage')
            .addButton(new ButtonBuilder().setLabel('Last').setCustomId('last'), 'LastPage');

        // Listens to pagination errors
        pagination.on('error', console.log);

        // Sends the pagination message
        await pagination.send({ command: interaction, sendAs: 'ReplyMessage' });
    }
});

bot.login('TOKEN');
```

### Reaction Pagination
> ⚠️ You cannot use reaction pagination with ephemeral messages

```js
const { ReactionPaginationBuilder } = require('@falloutstudios/djs-pagination');
const { Client, EmbedBuilder } = require('discord.js');

const bot = new Client({
    intents: ['Guilds', 'MessageContent', 'GuildMessageReactions']
});

bot.on('interactionCreate', async interaction => {
    if (interaction.isChatInputCommand() && interaction.commandName == 'pagination') {
        // Create pagination
        const pagination = new ReactionPaginationBuilder()
                // Add at least one page
            .addPages(
                new EmbedBuilder().setDescription('Page 1'), // Single embed page
                { content: 'Page 2', embeds: [{ title: 'Page 2' }] }, // Message data embed
                'Page 3', // String page
                () => new EmbedBuilder().setDescription('Page 4\n' + new Date().toString()) // Dynamic page
            )
            // All reaction controllers are optional
            .addReaction('⏪', 'FirstPage');
            .addReaction('⬅', 'PreviousPage');
            .addReaction('🛑', 'Stop');
            .addReaction('➡️', 'NextPage');
            .addReaction('⏩', 'LastPage');

        // Listens to pagination errors
        pagination.on('error', console.log);

        // Sends the pagination message
        await pagination.send({ command: interaction, sendAs: 'ReplyMessage' });
    }
});

bot.login('TOKEN');
```

---
_Source: https://npm.io/package/@falloutstudios/djs-pagination · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
