discord_bot/commands/help.js
SileNce5k c51a4fa976
Pass objects on command.execute
Pass objects instead of using a switch statement.
Now I don't have to restart the bot whenever I add a new command
that needs specific arguments other than 'message'.
2021-03-09 18:50:27 +01:00

38 lines
1.2 KiB
JavaScript

const fs = require('fs');
const Discord = require('discord.js');
const {prefix} = require('../config.json');
module.exports = {
name: 'help',
description: 'List all available commands.',
execute({message, args}) {
var commands = " "
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const embed = new Discord.MessageEmbed()
.setColor(15780145)
.setTitle("Commands")
.setTimestamp()
.setAuthor("soilens bot", "https://cdn.discordapp.com/avatars/481128222147477506/1a30f57f8e403f54aaca502012aeff14.png?size=2048")
for (const file of commandFiles) {
const command = require(`./${file}`);
if(args[0] == "admin"){
if (command.admin && !command.disabled)
commands = commands + `${prefix}${command.name} | ${command.description}\n`
}else
if(!command.admin && !command.disabled)
commands = commands + `${prefix}${command.name} | ${command.description}\n`
}
embed.addFields(
{ name: "General", value: commands },
)
message.channel.send(embed);
},
};