# oceanic-pagination

> A pagination library for oceanic.js

Latest version **1.0.2** (published 2023-05-20) · 0 weekly downloads

## Install

```sh
npm install oceanic-pagination
pnpm add oceanic-pagination
yarn add oceanic-pagination
bun add oceanic-pagination
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2023-05-20 |
| First published | 2023-04-23 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 109.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | ghextercortes |
| Keywords | oceanic.js, discord, pagination |

## Links

- npm: https://www.npmjs.com/package/oceanic-pagination
- Repository: https://github.com/NotGhex/oceanic-pagination
- Homepage: https://github.com/NotGhex/oceanic-pagination#readme
- Issues: https://github.com/NotGhex/oceanic-pagination/issues
- npm.io page: https://npm.io/package/oceanic-pagination

## Dependencies (2)

- [fallout-utility](https://npm.io/package/fallout-utility.md) ^2.4.1
- [oceanic-collector](https://npm.io/package/oceanic-collector.md) ^1.0.3

## Recent versions

- 1.0.2 (latest) — 2023-05-20
- 1.0.1 — 2023-04-23
- 1.0.0 — 2023-04-23

## README

# Oceanic Pagination
![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/oceanic-pagination?style=flat-square)
![GitHub](https://img.shields.io/github/license/NotGhex/djs-pagination?style=flat-square)
![npm (scoped)](https://img.shields.io/npm/v/oceanic-pagination?label=Latest%20Version&style=flat-square)

A simple button and reaction pagination library for Oceanic.js

## Installation

```bash
npm i oceanic-pagination oceanic.js
```

## Usage

### Button Pagination

```js
const { ButtonPaginationBuilder } = require('oceanic-pagination');
const { ButtonStyles, Client, ComponentTypes, InteractionTypes } = require('oceanic.js');

const bot = new Client({
    auth: 'Bot TOKEN_HERE',
    gateway: {
        intents: ['GUILDS', 'MESSAGE_CONTENT']
    }
});

bot.on('interactionCreate', async interaction => {
    if (interaction.type === InteractionTypes.APPLICATION_COMMAND && interaction.data.name === 'pagination') {
        // Create pagination
        const pagination = new ButtonPaginationBuilder({
            pages: [
                'Page 1',
                { author: { name: 'Page 2' } },
                { content: 'Page 3', embeds: [{ title: 'Page 3' }] },
                () => ({ author: { name: 'Page 4' } })
            ],
            buttons: [
                {
                    button: { type: ComponentTypes.BUTTON, label: 'First', customID: 'first', style: ButtonStyles.SECONDARY },
                    type: 'FirstPage'
                },
                {
                    button: { type: ComponentTypes.BUTTON, label: 'Previous', customID: 'prev', style: ButtonStyles.PRIMARY },
                    type: 'PreviousPage'
                },
                {
                    button: { type: ComponentTypes.STOP, label: 'Stop', customID: 'stop', style: ButtonStyles.DANGER },
                    type: 'Stop'
                },
                {
                    button: { type: ComponentTypes.BUTTON, label: 'Next', customID: 'next', style: ButtonStyles.PRIMARY },
                    type: 'NextPage'
                },
                {
                    button: { type: ComponentTypes.BUTTON, label: 'Last', customID: 'last', style: ButtonStyles.SECONDARY },
                    type: 'LastPage'
                },
            ]
        });

        // Listens to pagination errors
        pagination.on('error', console.log);

        // Sends the pagination message
        await pagination.send({ command: interaction, sendAs: 'ReplyMessage' });
    }
});

bot.connect();
```

### Reaction Pagination

> ⚠️ You cannot use reaction pagination with ephemeral messages

```js
const { ReactionPaginationBuilder } = require('oceanic-pagination');
const { Client } = require('oceanic.js');

const bot = new Client({
    auth: 'Bot TOKEN_HERE',
    gateway: {
        intents: ['GUILDS', 'MESSAGE_CONTENT', 'GUILD_MESSAGE_REACTIONS']
    }
});

bot.on('interactionCreate', async interaction => {
    if (interaction.type === InteractionTypes.APPLICATION_COMMAND && interaction.data.name === 'pagination') {
        // Create pagination
        const pagination = new ReactionPaginationBuilder({
            pages: [
                'Page 1',
                { author: { name: 'Page 2' } },
                { content: 'Page 3', embeds: [{ title: 'Page 3' }] },
                () => ({ author: { name: 'Page 4' } })
            ],
            reactions: [
                { emoji: '⏪', type: 'FirstPage' }
                { emoji: '⬅', type: 'PreviousPage' }
                { emoji: '🛑', type: 'Stop' }
                { emoji: '➡️', type: 'NextPage' }
                { emoji: '⏩', type: 'LastPage' }
            ]
        });

        // Listens to pagination errors
        pagination.on('error', console.log);

        // Sends the pagination message
        await pagination.send({ command: interaction, sendAs: 'ReplyMessage' });
    }
});

bot.connect();
```

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