Get files from top directory + rename file
* Generalise variable names * Change require stuff to the new thing
This commit is contained in:
parent
32dbcd062e
commit
047ba95311
4 changed files with 26 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
const getCommandFiles = require('../../util/getCommandFiles');
|
const getSubdirFiles = require('../../util/getSubdirFiles');
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -13,7 +13,7 @@ module.exports = {
|
||||||
],
|
],
|
||||||
execute({ message, args, prefix, client }) {
|
execute({ message, args, prefix, client }) {
|
||||||
let commands = ""
|
let commands = ""
|
||||||
let commandFiles = getCommandFiles('commands/')
|
let commandFiles = getSubdirFiles('commands/')
|
||||||
let x = 0
|
let x = 0
|
||||||
if (args[0] == "netmodules") {
|
if (args[0] == "netmodules") {
|
||||||
commandFiles = fs.readdirSync('../../netload').filter(file => file.endsWith('.js'));
|
commandFiles = fs.readdirSync('../../netload').filter(file => file.endsWith('.js'));
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
22
util/getSubdirFiles.js
Normal file
22
util/getSubdirFiles.js
Normal file
|
@ -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
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const getCommandFiles = require('./getCommandFiles');
|
const getSubdirFiles = require('./getSubdirFiles');
|
||||||
const commandPath = 'commands/'
|
const commandPath = 'commands/'
|
||||||
const utilPath = 'util/'
|
const utilPath = 'util/'
|
||||||
|
|
||||||
|
|
||||||
module.exports = function (client) {
|
module.exports = function (client) {
|
||||||
let utilFiles = fs.readdirSync(utilPath).filter(file => file.endsWith('.js'));
|
let utilFiles = fs.readdirSync(utilPath).filter(file => file.endsWith('.js'));
|
||||||
let commandFiles = getCommandFiles(commandPath);
|
let commandFiles = getSubdirFiles(commandPath);
|
||||||
|
|
||||||
|
|
||||||
if (client.commands.size != 0) {
|
if (client.commands.size != 0) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue