Add directory check
This commit is contained in:
parent
3ab4a66488
commit
83906b211d
1 changed files with 11 additions and 0 deletions
11
index.js
11
index.js
|
@ -2,12 +2,23 @@ const dc = require("discord.js");
|
||||||
const client = new dc.Client({intents: ["GUILDS", "GUILD_MESSAGES"]});
|
const client = new dc.Client({intents: ["GUILDS", "GUILD_MESSAGES"]});
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
|
|
||||||
|
function isDir(path){
|
||||||
|
try{
|
||||||
|
fs.readdirSync(path);
|
||||||
|
return true;
|
||||||
|
} catch(e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function parseCommands(){
|
function parseCommands(){
|
||||||
var cmdFiles = [];
|
var cmdFiles = [];
|
||||||
var indexes = {}
|
var indexes = {}
|
||||||
var rootdir = fs.readdirSync("Juustobotti/commands");
|
var rootdir = fs.readdirSync("Juustobotti/commands");
|
||||||
rootdir.forEach(categorydir => {
|
rootdir.forEach(categorydir => {
|
||||||
|
if(!isDir("Juustobotti/commands/" + categorydir)) return;
|
||||||
categorydir.forEach(file => {
|
categorydir.forEach(file => {
|
||||||
|
if(isDir("Juustobotti/commands/" + categorydir + "/" + file)) return;
|
||||||
indexes.file = categorydir;
|
indexes.file = categorydir;
|
||||||
cmdFiles.push(file);
|
cmdFiles.push(file);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue