parent
51a7178747
commit
86b3e57b4a
1 changed files with 9 additions and 5 deletions
|
@ -1,18 +1,22 @@
|
|||
const fs = require('fs')
|
||||
const filepath = 'commands/'
|
||||
const commandPath = 'commands/'
|
||||
const utilPath = 'util/'
|
||||
|
||||
|
||||
module.exports = function (client) {
|
||||
|
||||
let commandFiles = fs.readdirSync(filepath).filter(file => file.endsWith('.js'));
|
||||
let utilFiles = fs.readdirSync(utilPath).filter(file => file.endsWith('.js'));
|
||||
let commandFiles = fs.readdirSync(commandPath).filter(file => file.endsWith('.js'));
|
||||
if (client.commands.size != 0) {
|
||||
for (const i of commandFiles) {
|
||||
delete require.cache[require.resolve(`../${filepath}${i}`)];
|
||||
delete require.cache[require.resolve(`../${commandPath}${i}`)];
|
||||
}
|
||||
for (const i of utilFiles){
|
||||
delete require.cache[require.resolve(`../${utilPath}${i}`)]
|
||||
}
|
||||
}
|
||||
client.commands.clear()
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`../commands/${file}`);
|
||||
const command = require(`../${commandPath}${file}`);
|
||||
client.commands.set(command.name, command);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue