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.
19 lines
530 B
JavaScript
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);
|
|
}
|
|
}
|
|
|