npm i spud.js@latest
and then import into your project
const { PaginationBuilder } = require('spud.js');
// --- OR ---
import { PaginationBuilder } from 'spud.js';
To get started, make sure you have the necessary boilerplate for your discord bot. Then, within either an InteractionCreate
or MessageCreate
event, pass the corresponding object into the PaginationBuilder
constructor.
const { PaginationBuilder } = require('spud.js');
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isCommand()) return;
// ...
const pagination = new PaginationBuilder(interaction)
.setPages([
{
embed: new EmbedBuilder()
.setTitle('My first page.')
.setDescription('With a cool description'),
components: new ActionRowBuilder()
.setComponents(
new ButtonBuilder()
.setCustomId('page_one_button')
.setLabel('First page!')
.setStyle(ButtonStyle.Primary)
)
}
]);
await pagination.send();
})
This is all that's needed for an extremely basic pagination setup. There are various options you can adjust i.e additonal buttons, custom buttons, filters, collector options and more to fine tune exactly how you want it to operate.
Check your intellisense or browse the documentation to see all available options and join our discord server for any questions!