diff --git a/commands/info/help.js b/commands/info/help.js index 3efa236..92f0083 100644 --- a/commands/info/help.js +++ b/commands/info/help.js @@ -1,6 +1,6 @@ const fs = require('fs'); const Discord = require('discord.js'); -const getCommandFiles = require('../../util/getCommandFiles'); +const getSubdirFiles = require('../../util/getSubdirFiles'); module.exports = { @@ -13,7 +13,7 @@ module.exports = { ], execute({ message, args, prefix, client }) { let commands = "" - let commandFiles = getCommandFiles('commands/') + let commandFiles = getSubdirFiles('commands/') let x = 0 if (args[0] == "netmodules") { commandFiles = fs.readdirSync('../../netload').filter(file => file.endsWith('.js')); diff --git a/util/getCommandFiles.js b/util/getCommandFiles.js deleted file mode 100644 index 93f1bcc..0000000 --- a/util/getCommandFiles.js +++ /dev/null @@ -1,16 +0,0 @@ -const fs = require('fs') - -module.exports = function (commandPath) { - let subdir = fs.readdirSync(commandPath) - let commandFiles = []; - subdir.forEach(item => { - if(fs.statSync(commandPath+item).isDirectory()){ - let subdirFiles = fs.readdirSync(commandPath+item).filter(file => file.endsWith('.js')) - subdirFiles.forEach(file => { - commandFiles.push(commandPath+item+"/"+file) - }); - } - }); - - return commandFiles -} \ No newline at end of file diff --git a/util/getSubdirFiles.js b/util/getSubdirFiles.js new file mode 100644 index 0000000..437a035 --- /dev/null +++ b/util/getSubdirFiles.js @@ -0,0 +1,22 @@ +const fs = require('fs') + +module.exports = function (path) { + let subdir = fs.readdirSync(path) + let commandFiles = []; + subdir.forEach(item => { + if(fs.statSync(path+item).isDirectory()){ + let subdirFiles = fs.readdirSync(path+item) + subdirFiles.forEach(file => { + if(file.endsWith('.js')){ + commandFiles.push(path+item+"/"+file) + + } + }); + + }else if(item.endsWith('.js')){ + commandFiles.push(path+item) + } + }); + + return commandFiles +} diff --git a/util/reloadCommands.js b/util/reloadCommands.js index 4d2276a..eee8593 100644 --- a/util/reloadCommands.js +++ b/util/reloadCommands.js @@ -1,12 +1,12 @@ const fs = require('fs'); -const getCommandFiles = require('./getCommandFiles'); +const getSubdirFiles = require('./getSubdirFiles'); const commandPath = 'commands/' const utilPath = 'util/' module.exports = function (client) { let utilFiles = fs.readdirSync(utilPath).filter(file => file.endsWith('.js')); - let commandFiles = getCommandFiles(commandPath); + let commandFiles = getSubdirFiles(commandPath); if (client.commands.size != 0) {