Files
2024-03-02 21:42:57 +01:00

58 lines
2.0 KiB
TypeScript

import { Message } from "discord.js";
interface Command {
name: string;
aliases?: string[];
description: string;
emote?: string;
utilisation?: string;
category?: string;
}
module.exports = {
aliases: ['h', 'aide'],
description: 'Affiche la liste des commandes',
emote: '📚',
utilisation: '<commande>',
async execute(message: Message, args: string[], client: any) {
const prefix = '!!'
if (args[0]) {
const command = client.commands.get(args[0]);
if (!command) {
return message.edit(`Je n'ai pas trouvé de commande nommée "${args[0]}".`);
}
return message.edit(`# Aide pour la commande ${command.emote ? ` ${command.emote}` : '🔧'} ${command.name}\nUtilisation : \`${prefix}${command.name}${command.utilisation ? ` ${command.utilisation}` : ''}\`\nCatégorie : ${command.category || 'Non spécifiée'}\nAlias : ${command.aliases ? command.aliases.map((alias: string) => `\`${alias}\``).join(', ') : 'Aucun'}`);
} else {
let commands: Command[] = [];
for (const command of client.commands?.values() || []) {
const existingCommand = commands.find(cmd => cmd.name === command.name);
if (!existingCommand) {
commands.push(command);
}
}
let categories: { [key: string]: Command[] } = {};
commands.forEach((command: any) => {
if (!categories[command.category]) {
categories[command.category] = [];
}
categories[command.category]?.push(command);
});
let description = `Pour obtenir de l'aide sur les commandes faite ${prefix}help <commande>.\n Il y a ${commands.length} commandes disponibles\n\n`;
for (const [category, commands] of Object.entries(categories)) {
description += `**Catégorie ${category}**\n`;
description += commands.length > 0 ? '> ' + commands.map(command => `\`${command.name}\``).join(', ') : '> Aucune commande dans cette catégorie';
description += '\n\n';
}
message.edit(`# 📚 Information\n${description}`)
}
},
};