diff --git a/commands/help.js b/commands/help.js index e714c3f..ba515f5 100644 --- a/commands/help.js +++ b/commands/help.js @@ -5,7 +5,7 @@ const { SlashCommandBuilder } = require('discord.js'); const { DebugBuilder } = require("../utilities/debugBuilder"); const log = new DebugBuilder("server", "help"); -const prefix = process.env.PREFIX; +const { EmmeliaEmbedBuilder } = require("../libUtils"); const commandsPath = path.resolve(__dirname, '../commands'); // Resolves from either working dir or __dirname const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); @@ -18,23 +18,43 @@ module.exports = { isPrivileged: false, async execute(interaction) { try{ - messageText = ""; + generalCommandText = ""; + paidCommandText = ""; for (const file of commandFiles) { const filePath = path.join(commandsPath, file); const command = require(filePath); if (!command.isPrivileged){ // TODO - Need to add middleware for admins - if (messageText.length > 1 && messageText.slice(-2) != `\n`){ - messageText += `\n`; + if (!command.requiresTokens){ + if (generalCommandText.length > 1 && generalCommandText.slice(-2) != `\n`){ + generalCommandText += `\n\n`; + } + + generalCommandText += `**/${command.data.name}** - *${command.data.description}*`; + + if (command.example) generalCommandText += `\n\t\t***Usage:*** \`/${command.example}\`` } - - messageText += `**/${command.data.name}** - *${command.data.description}*`; - - if (command.example) messageText += `\n\t\t***Usage:*** \`${command.example}\`` + else{ + if (paidCommandText.length > 1 && paidCommandText.slice(-2) != `\n`){ + paidCommandText += `\n\n`; + } + + paidCommandText += `**/${command.data.name}** - *${command.data.description}*`; + + if (command.example) paidCommandText += `\n\t\t***Usage:*** \`/${command.example}\`` + } } } - await interaction.reply(messageText); + + const helpEmbed = new EmmeliaEmbedBuilder() + .setColor(0x0099FF) + .setTitle(`Help`) + .addFields( + { name: 'General Commands', value: `${generalCommandText}` }, + { name: 'Paid Commands', value: `${paidCommandText}` } + ) + await interaction.reply({ embeds: [helpEmbed], ephemeral: true }); }catch(err){ log.ERROR(err) //await interaction.reply(err.toString());