Files
Emmelia-Link-Flayer-Rewrite/commands/help.js
Logan Cusano d9a924e5f5 Update Help Command
- Added new parameters to commands for privileged commands
- Updated message to take new parameters into account
2023-02-24 20:16:21 -05:00

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);
}
};