discord_bot/util/reloadCommands.js
SileNce5k b89b926f9a
All checks were successful
CI / CI (push) Successful in 17s
Lint Codebase / eslint (push) Successful in 13s
Update actions/checkout to v4
2024-11-05 06:37:03 +01:00

25 lines
609 B
JavaScript

const getSubdirFiles = require('./getSubdirFiles');
const commandPath = 'commands/'
const utilPath = 'util/'
module.exports = function (client) {
let utilFiles = getSubdirFiles(utilPath)
let commandFiles = getSubdirFiles(commandPath);
if (client.commands.size != 0) {
for (const i of commandFiles) {
delete require.cache[require.resolve(`../${i}`)];
}
for (const i of utilFiles){
delete require.cache[require.resolve(`../${i}`)]
}
}
client.commands.clear()
for (const file of commandFiles) {
const command = require(`../${file}`);
client.commands.set(command.name, command);
}
}