Пост #148156 |
сохранен 10.10.2020 17:36
- Редактировать пост
- Печать
- Скачать
- Посты-ответы на этот пост: # 182331
- Посмотреть дерево постов
-
Сравнить с постом
#
Текст поста
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 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)) } } |