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

m00ny 439cdce934 Fix typo 2 years ago
examples 61acb25a94 First version of library! 2 years ago
src 8293af6ed9 Include license 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 eed6913a2b Update version 2 years ago
LICENSE.md 58a8a309e6 Rename LICENSE.MD to LICENSE.md 2 years ago
README.md 439cdce934 Fix typo 2 years ago
jest.config.json c67d76d31e Optimize jest config 2 years ago
package-lock.json 3ece4c5bb3 Update package-lock 2 years ago
package.json 0ef469e6a7 Change version 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 customizable embed pages with buttons. Works with Discord.JS starting from v13.

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.6.0 or newer (because of Discord.JS).

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

📃 Examples:

Basic example (previous page and next page buttons):

const {MessageEmbed, Client, MessageButton, Intents} = require('discord.js');
const {ChannelPagination, NextPageButton, PreviousPageButton} = require("djs-button-pages");

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

const buttons =
[
    new PreviousPageButton(new MessageButton().setCustomId("prev").setLabel("Previous").setStyle("PRIMARY")),
    new NextPageButton(new MessageButton().setCustomId("next").setLabel("Next").setStyle("PRIMARY")),
]

const client = new Client({intents: [Intents.FLAGS.GUILD, Intents.FLAGS.GUILD_MESSAGES]});

client.login("YOUR TOKEN");

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

client.on("messageCreate", async (message) => {
    if (message.content === "!pages")
    {
        const pagination = await new ChannelPagination() //Create pagination.
            .setButtons(buttons) //Pass buttons.
            .setEmbeds(embeds) //Pass embeds.
            .setTime(60000) //Set life-time to 60000.
            .send(message.channel); //Send.
    };
});

More complicated and interesting examples with commentary can be found at GitHub page. There is also documentation that you can read for more information.

❔ 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.