if (!args.length) return message.channel.send(`You didn't pass any command to reload!`); const commandName = args[0].toLowerCase(); if (message.client.commands.get(commandName)) { const command = message.client.commands.get(commandName) || message.client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)); if (!command) return message.channel.send(`There is no command with name or alias \`${commandName}\`, ${message.author}!`); const fs = require('fs'); const commandFolders = fs.readdirSync('./commands'); for (const folder of commandFolders) { const CommandFiles = fs.readdirSync(`./commands/${folder}`).filter(file => file.endsWith('.js')); for (const file of CommandFiles) { delete require.cache[require.resolve(`../${folder}/${file}`)]; try { const newCommand = require(`../${folder}/${file}`); client.commands.set(commandName, newCommand); return message.channel.send("Command `" + commandName + "` was reloaded!"); } catch (error) { message.channel.send("There was an error while reloading the `" + `${prefix}` + commandName + `command. \n\nError is as follows:\n${error.message}`); } } //+reload } }