- Added new parameters to commands for privileged commands - Updated message to take new parameters into account
30 lines
941 B
JavaScript
30 lines
941 B
JavaScript
const fs = require('fs');
|
|
const path = require('node:path');
|
|
|
|
const prefix = process.env.PREFIX;
|
|
|
|
module.exports = {
|
|
name: 'help',
|
|
description: 'Display this help message',
|
|
example: "help",
|
|
execute(message) {
|
|
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);
|
|
|
|
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);
|
|
}
|
|
}; |