Compare Pastes
Differences between the pastes
#148156 (10.10.2020 17:36)
and
#182331 (12.05.2021 07:21).
1 | const Discord = require("discord.js"); | |
2 | const fs = require('fs'); | |
3 | let connection; | |
4 | ||
5 | (async () => { | |
6 | connection = await require('../db'); | |
7 | })(); | |
8 | ||
9 | module.exports = { | |
10 | name: 'help', | |
11 | description: 'Permet d\'obtenir la liste de toutes les commandes ou d\'une commande en particulier.', | |
12 | args: false, | |
13 | guildOnly: false, | |
14 | category: "utilitaire", | |
15 | usage: "[commande]", | |
16 | execute(client, message, args) { | |
17 | let commact; | |
18 | const guildCommandPrefix = new Map(); | |
19 | const guildLangfile = new Map(); | |
20 | const guildCommact = new Map(); | |
21 | ||
22 | connection.query( | |
23 | `SELECT * FROM GuildConfigurable WHERE guildId = '${message.guild.id}'` | |
24 | ).then(result => { | |
25 | guildLangfile.set(message.guild.id, result[0][0].Lang); | |
26 | guildCommandPrefix.set(message.guild.id, result[0][0].cmdPrefix); | |
27 | const prefix = guildCommandPrefix.get(message.guild.id) | |
28 | const langue = guildLangfile.get(message.guild.id) | |
29 | ||
30 | const lan = fs.readFileSync(`./src/languages/help/${langue}.json`); | |
31 | client.lang = JSON.parse(lan); | |
32 | const { txthelp1, txthelp2a, txthelp2b, txtticket, txtmusic, txtinfo, txtutils, txtmod, txtfun, ncerr, txtnom, txtdesc, txtuse, txtcat } = client.lang; | |
33 | ||
34 | const { commands } = message.client; | |
35 | const embed = new Discord.MessageEmbed() | |
36 | .setFooter(message.client.user.username, message.client.user.avatarURL()) | |
37 | .setTimestamp() | |
38 | .setColor(593528); | |
39 | ||
40 | if (!args.length) { | |
41 | embed.setTitle(txthelp1) | |
42 | .setDescription(`${txthelp2a}${prefix}${txthelp2b}`); | |
43 | let ticket = ""; | |
44 | let utils = ""; | |
45 | let music = ""; | |
46 | let info = ""; | |
47 | let moderation = ""; | |
48 | let fun = ""; | |
49 | commands.forEach(command => { | |
50 | const cmdname = command.name | |
51 | connection.query( | |
52 | `SELECT ${cmdname} FROM GuildConfigurable WHERE guildId = '${message.guild.id}'` | |
53 | ).then(result => { | |
54 | ||
55 | guildCommact.set(message.guild.id, result[0][0]) | |
56 | commact = guildCommact.get(message.guild.id) | |
57 | }) | |
58 | console.log(commact) | |
59 | ||
60 | if (commact == `false`) { | |
61 | console.log("OK !") | |
62 | } | |
63 | if (command.category === "ticket") { | |
64 | ticket += `**${prefix}${command.name} :** ${command.description}\n`; | |
65 | } | |
66 | if (command.category === "musique") { | |
67 | music += `**${prefix}${command.name} :** ${command.description}\n`; | |
68 | } | |
69 | if (command.category === "information") { | |
70 | info += `**${prefix}${command.name} :** ${command.description}\n`; | |
71 | } | |
72 | if (command.category === "utilitaire") { | |
73 | utils += `**${prefix}${command.name} :** ${command.description}\n`; | |
74 | } | |
75 | if (command.category === "moderation") { | |
76 | moderation += `**${prefix}${command.name} :** ${command.description}\n`; | |
77 | } | |
78 | if (command.category === "fun") { | |
79 | fun += `**${prefix}${command.name} :** ${command.description}\n`; | |
80 | } | |
81 | }) | |
82 | if (ticket !== "") embed.addField(txtticket, ticket, false); | |
83 | if (music !== "") embed.addField(txtmusic, music, false); | |
84 | if (info !== "") embed.addField(txtinfo, info, false); | |
85 | if (utils !== "") embed.addField(txtutils, utils, false); | |
86 | if (moderation !== "") embed.addField(txtmod, moderation, false); | |
87 | if (fun !== "") embed.addField(txtfun, fun, false); | |
88 | return message.channel.send(embed); | |
89 | } | |
90 | ||
91 | const name = args[0].toLowerCase(); | |
92 | const command = commands.get(name); | |
93 | ||
94 | if (!command) { | |
95 | return message.reply(ncerr).then(msg => msg.delete({ timeout: 5000 })); | |
96 | } | |
97 | embed.addField(txtnom, `${command.name}`); | |
98 | ||
99 | if (command.description) embed.addField(txtdesc, `${command.description}`); | |
100 | embed.addField(txtuse, `${prefix}${command.name} ${command.usage}`); | |
101 | if (command.category) embed.addField(txtcat, `${command.category}`); | |
102 | ||
103 | message.channel.send(embed); | |
104 | ||
105 | }).catch(err => console.log(err)) | |
106 | } |