const Discord = require("discord.js"); const fs = require('fs'); let connection; (async () => { connection = await require('../db'); })(); module.exports = { name: 'help', description: 'Permet d\'obtenir la liste de toutes les commandes ou d\'une commande en particulier.', args: false, guildOnly: false, category: "utilitaire", usage: "[commande]", execute(client, message, args) { let commact; const guildCommandPrefix = new Map(); const guildLangfile = new Map(); const guildCommact = new Map(); connection.query( `SELECT * FROM GuildConfigurable WHERE guildId = '${message.guild.id}'` ).then(result => { guildLangfile.set(message.guild.id, result[0][0].Lang); guildCommandPrefix.set(message.guild.id, result[0][0].cmdPrefix); const prefix = guildCommandPrefix.get(message.guild.id) const langue = guildLangfile.get(message.guild.id) const lan = fs.readFileSync(`./src/languages/help/${langue}.json`); client.lang = JSON.parse(lan); const { txthelp1, txthelp2a, txthelp2b, txtticket, txtmusic, txtinfo, txtutils, txtmod, txtfun, ncerr, txtnom, txtdesc, txtuse, txtcat } = client.lang; const { commands } = message.client; const embed = new Discord.MessageEmbed() .setFooter(message.client.user.username, message.client.user.avatarURL()) .setTimestamp() .setColor(593528); if (!args.length) { embed.setTitle(txthelp1) .setDescription(`${txthelp2a}${prefix}${txthelp2b}`); let ticket = ""; let utils = ""; let music = ""; let info = ""; let moderation = ""; let fun = ""; commands.forEach(command => { const cmdname = command.name connection.query( `SELECT ${cmdname} FROM GuildConfigurable WHERE guildId = '${message.guild.id}'` ).then(result => { guildCommact.set(message.guild.id, result[0][0]) commact = guildCommact.get(message.guild.id) }) console.log(commact) if (commact == `false`) { console.log("OK !") } if (command.category === "ticket") { ticket += `**${prefix}${command.name} :** ${command.description}\n`; } if (command.category === "musique") { music += `**${prefix}${command.name} :** ${command.description}\n`; } if (command.category === "information") { info += `**${prefix}${command.name} :** ${command.description}\n`; } if (command.category === "utilitaire") { utils += `**${prefix}${command.name} :** ${command.description}\n`; } if (command.category === "moderation") { moderation += `**${prefix}${command.name} :** ${command.description}\n`; } if (command.category === "fun") { fun += `**${prefix}${command.name} :** ${command.description}\n`; } }) if (ticket !== "") embed.addField(txtticket, ticket, false); if (music !== "") embed.addField(txtmusic, music, false); if (info !== "") embed.addField(txtinfo, info, false); if (utils !== "") embed.addField(txtutils, utils, false); if (moderation !== "") embed.addField(txtmod, moderation, false); if (fun !== "") embed.addField(txtfun, fun, false); return message.channel.send(embed); } const name = args[0].toLowerCase(); const command = commands.get(name); if (!command) { return message.reply(ncerr).then(msg => msg.delete({ timeout: 5000 })); } embed.addField(txtnom, `${command.name}`); if (command.description) embed.addField(txtdesc, `${command.description}`); embed.addField(txtuse, `${prefix}${command.name} ${command.usage}`); if (command.category) embed.addField(txtcat, `${command.category}`); message.channel.send(embed); }).catch(err => console.log(err)) } }