Add directory check

This commit is contained in:
Ecolipsy 2021-12-02 17:07:01 +01:00
parent 3ab4a66488
commit 83906b211d

View file

@ -2,12 +2,23 @@ const dc = require("discord.js");
const client = new dc.Client({intents: ["GUILDS", "GUILD_MESSAGES"]});
const fs = require("fs");
function isDir(path){
try{
fs.readdirSync(path);
return true;
} catch(e){
return false;
}
}
function parseCommands(){
var cmdFiles = [];
var indexes = {}
var rootdir = fs.readdirSync("Juustobotti/commands");
rootdir.forEach(categorydir => {
if(!isDir("Juustobotti/commands/" + categorydir)) return;
categorydir.forEach(file => {
if(isDir("Juustobotti/commands/" + categorydir + "/" + file)) return;
indexes.file = categorydir;
cmdFiles.push(file);
});