Split commands into subdirectories
* Move command files into directories * Edit relative paths * Update gitignore * Finish support for commands in subdir * Split up getCommandFiles into own function * Add support for subdirs on help command
This commit is contained in:
parent
8993eeaf7a
commit
e7cdd425d1
21 changed files with 55 additions and 35 deletions
|
@ -1,11 +1,14 @@
|
|||
const fs = require('fs')
|
||||
const fs = require('fs');
|
||||
const getCommandFiles = require('./getCommandFiles');
|
||||
const commandPath = 'commands/'
|
||||
const utilPath = 'util/'
|
||||
|
||||
|
||||
module.exports = function (client) {
|
||||
let utilFiles = fs.readdirSync(utilPath).filter(file => file.endsWith('.js'));
|
||||
let commandFiles = fs.readdirSync(commandPath).filter(file => file.endsWith('.js'));
|
||||
let commandFiles = getCommandFiles(commandPath);
|
||||
|
||||
|
||||
if (client.commands.size != 0) {
|
||||
for (const i of commandFiles) {
|
||||
delete require.cache[require.resolve(`../${commandPath}${i}`)];
|
||||
|
@ -16,7 +19,7 @@ module.exports = function (client) {
|
|||
}
|
||||
client.commands.clear()
|
||||
for (const file of commandFiles) {
|
||||
const command = require(`../${commandPath}${file}`);
|
||||
const command = require(`../${file}`);
|
||||
client.commands.set(command.name, command);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue