discord_bot/util/reloadCommands.js
SileNce5k 0bfeb8d3b6
Remove TODO
Not gonna implement reloading a specific module. I don't really see it
being worth it as it doesn't take a long time to just reload everything.
2021-03-10 21:10:55 +01:00

19 lines
530 B
JavaScript

const fs = require('fs')
const filepath = 'commands/'
module.exports = function (client) {
let commandFiles = fs.readdirSync(filepath).filter(file => file.endsWith('.js'));
if (client.commands.size != 0) {
for (const i of commandFiles) {
delete require.cache[require.resolve(`../${filepath}${i}`)];
}
}
client.commands.clear()
for (const file of commandFiles) {
const command = require(`../commands/${file}`);
client.commands.set(command.name, command);
}
}