Fast, reliable and easy to use modern library to implement customizable embed pages in Discord Chat.

m00ny c44c5a2333 Hotfix 2 years ago
examples 02bad5dbed Update examples 2 years ago
src c44c5a2333 Hotfix 2 years ago
tests e4214d4f7a More complicated tests are added 2 years ago
.eslintignore 56a509ed4e Setted up a linter. 2 years ago
.eslintrc 56a509ed4e Setted up a linter. 2 years ago
.gitignore d5c6e9ebee Include coverage into gitignore 2 years ago
CHANGELOG.md c44c5a2333 Hotfix 2 years ago
LICENSE.md 58a8a309e6 Rename LICENSE.MD to LICENSE.md 2 years ago
README.md 384dc341f4 Update README.md 2 years ago
jest.config.json c67d76d31e Optimize jest config 2 years ago
package-lock.json 7a228e32ab Update to support v14 2 years ago
package.json c44c5a2333 Hotfix 2 years ago
tsconfig.json 61acb25a94 First version of library! 2 years ago

README.md


logo

npm-version npm-downloads github-issues

📚 About package:

Simple yet powerful module to create fully-customizable embed pages with buttons. Works with Discord.JS. Supports v13 and v14.

This package supports creation of custom buttons with custom scripts through a simple API.

Advantages:

  • Object-oriented.
  • Predictable.
  • Fast.
  • Customizable.

📥 Installation:

Requires Node.js 16.9.0 or newer (because of Discord.JS).

npm install djs-button-pages
yarn add djs-button-pages
pnpm add djs-button-pages

For v13 (requires Node.js 16.6.0 or newer):

npm install djs-button-pages@djs13
yarn add djs-button-pages@djs13
pnpm add djs-button-pages@djs13

📃 Examples:

Basic example (previous page and next page buttons):

const { Client, EmbedBuilder, ButtonStyle, IntentsBitField } = require("discord.js");
const { ChannelPagination, NextPageButton, PreviousPageButton } = require("djs-button-pages");

const embeds =
[
    new EmbedBuilder().setDescription("1"),
    new EmbedBuilder().setDescription("2"),
    new EmbedBuilder().setDescription("3"),
    new EmbedBuilder().setDescription("4"),
    new EmbedBuilder().setDescription("5"),
    new EmbedBuilder().setDescription("6"),
    new EmbedBuilder().setDescription("7"),
    new EmbedBuilder().setDescription("8"),
];

const buttons = 
[
    new PreviousPageButton({custom_id: "prev_page", label: "Previous", style: ButtonStyle.Success}),
    new NextPageButton().setStyle({custom_id: "next_page", label: "Next", style: ButtonStyle.Success}),
];

//These very bitfields are needed for this example.
const client = new Client({intents: [IntentsBitField.Flags.GuildMessages, IntentsBitField.Flags.Guilds, IntentsBitField.Flags.MessageContent]});

client.once("ready", () => {
    console.log("Ready!");
});

client.on("messageCreate", async (message) => {
    if (message.content === "!pages")
    {
        const pagination = new ChannelPagination() //Create pagination.
            .setButtons(buttons) //Insert buttons.
            .setEmbeds(embeds) //Add embeds.
            .setTime(60000); //Set time.

        await pagination.send(message.channel); //Send!
    };
});

//Login.
client.login("YOUR TOKEN");

More complicated and interesting examples with commentary may be found at GitHub page.

❔ Links:

🐛 Bug reporting

For bug-reporting look for GitHub Issues.

Or you can DM me in Discord: moony#6815.

© License:

Copyright © 2022 Danila Kononov (nickname: moony). All rights reserved.

Licensed under the Apache License, Version 2.0.