This commit is contained in:
Tutur33
2024-02-23 21:13:06 +01:00
parent 66b669a0e1
commit d85c18f7ed
5 changed files with 95 additions and 4 deletions
+89
View File
@@ -0,0 +1,89 @@
const { EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder } = require("discord.js")
/*
module.exports = {
aliases: ['h', 'aide'],
description: 'Affiche la liste des commandes',
emote: '📚',
utilisation: '[commande]',
async execute(message, args, client) {
console.log("Liste des commandes :");
let commands = [];
for (const command of client.commands.values()) {
const existingCommand = commands.find(cmd => cmd.name === command.name);
if (!existingCommand) {
commands.push(command);
}
}
console.log(commands);
},
};
*/
module.exports = {
aliases: ['h', 'aide'],
description: 'Affiche la liste des commandes',
emote: '📚',
utilisation: '[commande]',
async execute(message, args, client) {
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 => `\`${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 = [];
for (const command of client.commands.values()) {
const existingCommand = commands.find(cmd => cmd.name === command.name);
if (!existingCommand) {
commands.push(command);
}
}
let categories = {};
commands.forEach((command) => {
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.name}\` - ${command.description}`).join('\n')
});
}
message.channel.send({ embeds: [embed] });
}
},
};
-1
View File
@@ -1,7 +1,6 @@
const { ButtonStyle, ButtonBuilder, ActionRowBuilder } = require('discord.js');
module.exports = {
name: 'ping',
aliases: ['latence'],
description: 'Avoir la latence du bot.',
emote: '⏱️',
-1
View File
@@ -3,7 +3,6 @@ const sqlite3 = require('sqlite3').verbose();
require('dotenv').config();
module.exports = {
name: 'setprefix',
aliases: ['prefixset'],
description: 'Changer le préfixe du bot.',
emote: '⏱️',
+1 -1
View File
@@ -19,7 +19,7 @@ module.exports = {
if (permissionLevel < command.permission) return message.reply("Vous n'avez pas la permission d'utiliser cette commande");
try {
command.execute(message, args);
command.execute(message, args, client);
} catch (error) {
console.error(error);
message.reply("Erreur lors de l'exécution de la commande");
+5 -1
View File
@@ -12,7 +12,11 @@ module.exports = function loadEvents(client, dir) {
try {
delete require.cache[require.resolve(filePath)];
const command = require(filePath);
client.commands.set(command.name, command);
const fileName = file.replace('.js', '');
command.name = fileName;
const parentDir = path.basename(path.dirname(filePath));
command.category = parentDir === 'commands' ? 'other' : parentDir;
client.commands.set(fileName, command);
if (command.aliases) {
command.aliases.forEach(alias => {
client.commands.set(alias, command);