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);
}
}