mirror of
https://github.com/arthur-pbty/gestion-perso.git
synced 2026-06-06 14:20:38 +02:00
77 lines
2.7 KiB
TypeScript
77 lines
2.7 KiB
TypeScript
import { Message, EmbedBuilder } 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.reply(`Je n'ai pas trouvé de commande nommée "${args[0]}".`);
|
|
}
|
|
|
|
const commandPerm = 'None';
|
|
|
|
const embed_command = new EmbedBuilder()
|
|
.setColor('#0099ff')
|
|
.setTitle(`Aide pour la commande ${command.emote ? ` ${command.emote}` : '🔧'} ${command.name}`)
|
|
.setDescription(command.description)
|
|
.addFields(
|
|
{ name: 'Utilisation', value: `\`${prefix}${command.utilisation ? `${command.utilisation}` : ''}\``, inline: true },
|
|
{ name: 'Catégorie', value: command.category || 'Non spécifiée', inline: true },
|
|
{ name: 'Alias', value: command.aliases ? command.aliases.map((alias: string) => `\`${alias}\``).join(', ') : 'Aucun', inline: true },
|
|
{ name: 'Permissions', value: `Perm level: ${commandPerm}` || 'Indéfini', inline: true },
|
|
)
|
|
.setTimestamp()
|
|
.setFooter({ text: `${client.user?.tag} © 2024`, iconURL: client.user?.displayAvatarURL({ dynamic: true })});
|
|
|
|
return message.reply({ embeds: [embed_command] });
|
|
|
|
} 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);
|
|
});
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setTitle('Liste des commandes')
|
|
.setDescription('Sélectionnez une catégorie parmi les options ci-dessous pour obtenir de l\'aide sur les commandes correspondantes.')
|
|
.setColor('#0099ff');
|
|
|
|
for (const [category, commands] of Object.entries(categories)) {
|
|
embed.addFields({
|
|
name: `Catégorie ${category}`,
|
|
value: commands.map((command: Command) => `\`${command.name}\` - ${command.description}`).join('\n')
|
|
});
|
|
}
|
|
|
|
message.channel.send({ embeds: [embed] });
|
|
}
|
|
},
|
|
}; |