diff --git a/commands/help.js b/commands/help.js index 3c36909..e32eb04 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,43 +1,30 @@ -var libFlayer = require("../libFlayer.js"); +const fs = require('fs'); +const path = require('node:path'); -const prefix = process.env.prefix; +const prefix = process.env.PREFIX; module.exports = { name: 'help', - description: 'Help', + description: 'Display this help message', + example: "help", execute(message) { - message.reply( - `**${prefix}help** - *Lists the available commands* + messageText = ""; + const commandsPath = path.resolve('./commands'); // Resolves from either working dir or __dirname + const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js')); + for (const file of commandFiles) { + const filePath = path.join(commandsPath, file); + const command = require(filePath); - **${prefix}add** - Add a new RSS Source: *${prefix}add http://www.engadget.com/rss.xml* - **${prefix}alert** - Gets weather alerts for an area: *${prefix}alert TX* - **${prefix}answer** - Answers for a question above: *${prefix}answer 1* - - **${prefix}chat** - Queries OpenAI: *${prefix}chat what is a pizza* - **${prefix}calc** - Do math: *${prefix}calc 2 + 2* - **${prefix}categories** - Displays Categories: *${prefix}categories* - **${prefix}code** - Searches for code snippets: *${prefix}code python loop* - - **${prefix}find** - Searches the RSS Sources: *${prefix}find google* - **${prefix}food** - Selects a random recipe: *${prefix}food* - - **${prefix}get** - Retrieves Search By Index: *${prefix}get 25* - - **${prefix}key** - Testing key from storage: *${prefix}key keyName* - - **${prefix}npm** - Gets NPM info from repository: *${prefix}npm axios* - - **${prefix}quote** - Selects a random quote: *${prefix}quote* - - **${prefix}random** - Selects a random article: *${prefix}random* - **${prefix}random category** - Selects a random article by category: *${prefix}random sports* - - **${prefix}search** - Instant Live Search: *${prefix}search salesforce* - **${prefix}slang** - Urban Dictionary Search: *${prefix}slang slang* - **${prefix}stock** - AlphaVantage Stock Search: *${prefix}stock IBM* - - **${prefix}update** - Updates all current RSS Feeds: *${prefix}update* - ` - ); + if (!command.isPrivileged){ // TODO - Need to add middleware for admins + if (messageText.length > 1 && messageText.slice(-2) != `\n`){ + messageText += `\n`; + } + + messageText += `**${prefix}${command.name}** - *${command.description}*`; + + if (command.example) messageText += `\n\t\t***Usage:*** \`${command.example}\`` + } + } + message.reply(messageText); } }; \ No newline at end of file