Pagination

does sapphire have something for this?
5 Replies
untitled.
untitled.OP13mo ago
import { Command, CommandStore } from '@sapphire/framework';
import { EmbedBuilder, type Client, type Message } from 'discord.js';
export class HelpCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: 'help',
aliases: ['h'],
description: 'the help command'
});
}

public async messageRun(message: Message) {
const cmds = this.container.stores.get('commands');
const categories = new Map<string, Command[]>();

cmds.forEach((cmd) => {
const category = cmd.category || 'Uncategorized';
const list = categories.get(category) || [];
list.push(cmd);
categories.set(category, list);
});

const embeds = [];
for (const [category, commands] of categories) {
const embed = new EmbedBuilder()
.setTitle(`Help - ${category}`)
.setDescription(commands.map((cmd) => cmd.name).join(', '))
.setColor('#0099ff');
embeds.push(embed);
}

const pagination = new Pagination(embeds);
await pagination.send(message.channel);

}
}
import { Command, CommandStore } from '@sapphire/framework';
import { EmbedBuilder, type Client, type Message } from 'discord.js';
export class HelpCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, {
...options,
name: 'help',
aliases: ['h'],
description: 'the help command'
});
}

public async messageRun(message: Message) {
const cmds = this.container.stores.get('commands');
const categories = new Map<string, Command[]>();

cmds.forEach((cmd) => {
const category = cmd.category || 'Uncategorized';
const list = categories.get(category) || [];
list.push(cmd);
categories.set(category, list);
});

const embeds = [];
for (const [category, commands] of categories) {
const embed = new EmbedBuilder()
.setTitle(`Help - ${category}`)
.setDescription(commands.map((cmd) => cmd.name).join(', '))
.setColor('#0099ff');
embeds.push(embed);
}

const pagination = new Pagination(embeds);
await pagination.send(message.channel);

}
}
untitled.
untitled.OP13mo ago
that last 2 lines was generated by AI
untitled.
untitled.OP13mo ago
can i remove the dropdown
No description
Favna
Favna13mo ago
Use setActions and array filter on the default actions.
Want results from more Discord servers?
Add your server