diff --git a/commands/bot control/help.js b/commands/bot control/help.js index 60bd4af..77737e2 100644 --- a/commands/bot control/help.js +++ b/commands/bot control/help.js @@ -1,7 +1,8 @@ const { EmbedBuilder, ButtonStyle, ButtonBuilder, ActionRowBuilder } = require('discord.js'); const embedColor = require('../../fonctions/embedColor.js'); +const getPrefix = require('../../fonctions/getPrefix.js'); -function commandsList (client, category) { +function commandsList (client, category, prefix) { const casinoCommands = client.commands.filter(command => command.category === category).sort((a, b) => a.name.localeCompare(b.name)); const uniqueCommands = new Map(); @@ -11,7 +12,7 @@ function commandsList (client, category) { let commandsList = ''; uniqueCommands.forEach((command, name) => { - commandsList += `> ${command.emote} \`${name}${command.utilisation ? ' ' + command.utilisation : ''}\`\n> ┖ ${command.description}\n\n`; + commandsList += `> ${command.emote} \`${prefix}${name}${command.utilisation ? ' ' + command.utilisation : ''}\`\n> ┖ ${command.description}\n\n`; }); return commandsList; @@ -25,10 +26,11 @@ module.exports = { permission: 0, async execute(message, args, client) { + const prefix = await getPrefix(message.guild.id); const embedPage1 = new EmbedBuilder() .setTitle('📚 ・Information') .setThumbnail(message.guild.iconURL()) - .setDescription(`Voici le panel d'aide du bot. Pour plus d'informations sur une commande, utilisez &help \n\n> **🎙️ Récompenses vocales :**\n> Vous gagnez \`100\` coins toutes les \`15\`minutes lorsque vous êtes en vocal (**NON MUTE** sinon c'est \`50\`coins).\n \n> **📺 Récompenses de streaming :**\n> Activer un stream vous fera gagner \`200\`.\n \n> **📷 Récompenses de caméra :**\n> Activer votre caméra vous fera gagner \`200\`.\n\n> Le coins est une monnaie fictive.`) + .setDescription(`Voici le panel d'aide du bot. Pour plus d'informations sur une commande, utilisez ${prefix}help \n\n> **🎙️ Récompenses vocales :**\n> Vous gagnez \`100\` coins toutes les \`15\`minutes lorsque vous êtes en vocal (**NON MUTE** sinon c'est \`50\`coins).\n \n> **📺 Récompenses de streaming :**\n> Activer un stream vous fera gagner \`200\`.\n \n> **📷 Récompenses de caméra :**\n> Activer votre caméra vous fera gagner \`200\`.\n\n> Le coins est une monnaie fictive.`) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Page 1/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }); @@ -67,7 +69,7 @@ module.exports = { const embedPage2 = new EmbedBuilder() .setTitle('💰・Casino') .setThumbnail(message.guild.iconURL()) - .setDescription(commandsList(client, 'casino')) + .setDescription(commandsList(client, 'casino', prefix)) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Page 2/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }); @@ -77,7 +79,7 @@ module.exports = { const embedPage3 = new EmbedBuilder() .setTitle('🎲・Jeux') .setThumbnail(message.guild.iconURL()) - .setDescription(commandsList(client, 'jeux')) + .setDescription(commandsList(client, 'jeux', prefix)) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Page 3/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }); @@ -87,7 +89,7 @@ module.exports = { const embedPage4 = new EmbedBuilder() .setTitle('🛍️・Achats') .setThumbnail(message.guild.iconURL()) - .setDescription(commandsList(client, 'achats')) + .setDescription(commandsList(client, 'achats', prefix)) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Page 4/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }); @@ -97,7 +99,7 @@ module.exports = { const embedPage5 = new EmbedBuilder() .setTitle('🏭・Metier et capacité') .setThumbnail(message.guild.iconURL()) - .setDescription(commandsList(client, 'jobs')) + .setDescription(commandsList(client, 'jobs', prefix)) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Page 5/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }); @@ -107,7 +109,7 @@ module.exports = { const embedPage6 = new EmbedBuilder() .setTitle('💼・Teams') .setThumbnail(message.guild.iconURL()) - .setDescription(commandsList(client, 'teams')) + .setDescription(commandsList(client, 'teams', prefix)) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Page 6/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }); @@ -117,7 +119,7 @@ module.exports = { const embedPage7 = new EmbedBuilder() .setTitle('🛡️・Teams administration') .setThumbnail(message.guild.iconURL()) - .setDescription(commandsList(client, 'teams admin')) + .setDescription(commandsList(client, 'teams admin', prefix)) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Page 7/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }); @@ -137,7 +139,7 @@ module.exports = { const embedPage9 = new EmbedBuilder() .setTitle('👑・Gestion') .setThumbnail(message.guild.iconURL()) - .setDescription(commandsList(client, 'gestion')) + .setDescription(commandsList(client, 'gestion', prefix)) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Page 9/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }); @@ -147,7 +149,7 @@ module.exports = { const embedPage10 = new EmbedBuilder() .setTitle('👑・Bot control') .setThumbnail(message.guild.iconURL()) - .setDescription(commandsList(client, 'bot control')) + .setDescription(commandsList(client, 'bot control', prefix)) .setColor(await embedColor(message.author.id, message.guild.id)) .setTimestamp() .setFooter({ text: `Page 10/10 | Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }); diff --git a/fonctions/getPrefix.js b/fonctions/getPrefix.js new file mode 100644 index 0000000..5b87cbc --- /dev/null +++ b/fonctions/getPrefix.js @@ -0,0 +1,12 @@ +const db = require('./database.js'); + +module.exports = async function getPrefix(serverId) { + const prefix = await new Promise((resolve, reject) => { + db.get(`SELECT * FROM config WHERE guildId = ? AND name = ?`, [serverId, 'prefix'], (err, row) => { + if (err) reject(err); + resolve(row); + }); + }); + + return prefix ? prefix.value : '&'; +} \ No newline at end of file