Paginate embeds in Discord.js.
Installation
npm install @not_i9/paginate
Example
// CommonJS
const { paginate } = require("@not_i9/paginate");
// ESM
import { paginate } from "@not_i9/paginate";
// Usage
// interaction must be a ChatInputCommandInteraction
const client = new Client();
const embeds = [
new EmbedBuilder().setDescription("First embed"),
new EmbedBuilder().setDescription("Second embed"),
new EmbedBuilder().setDescription("Third embed"),
];
client.on("interactionCreate", async (interaction) => {
if (!interaction.isChatInputCommand()) return;
if (interaction.commandName === "test") {
await paginate(interaction, embeds, {
time: 30000, // In milleseconds. Default is 30 seconds, which is the minimum.
buttons: { // Customize button emojis and labels.
EXAMPLE_BUTTON: {
// Both or one of the following must be used.
emoji: "1234567890", // Emoji ID.
text: "TEXT HERE" // Button label.
},
previous: {
emoji: "12345",
text: "Previous Page",
},
next: {
text: "Next Page"
},
start: {
emoji: "67890"
}
// previous, next, and start are the only options.
// For now, you cannot add any more buttons.
}
});
}
});