From 1541f5cf42dff5fd12f11d758593a87c15b607c8 Mon Sep 17 00:00:00 2001 From: litruv Date: Tue, 19 Mar 2019 03:31:11 +1100 Subject: [PATCH] Try/catch on loading commands --- index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 8346b4c..283dd5f 100644 --- a/index.js +++ b/index.js @@ -41,10 +41,16 @@ class Commands { loadcommands() { fs.readdir("./commands/", function (err, items) { for (var i = 0; i < items.length; i++) { - var reqcommand = require('./commands/' + items[i]) - for (var z = 0; z < reqcommand.alias.length; z++) { - var cachedcommand = new CachedCommand(reqcommand.alias[z], items[i]) - client.cachedcommands.push(cachedcommand) + try { + var reqcommand = require('./commands/' + items[i]) + for (var z = 0; z < reqcommand.alias.length; z++) { + var cachedcommand = new CachedCommand(reqcommand.alias[z], items[i]) + client.cachedcommands.push(cachedcommand) + } + + } catch (error) { + console.log('error with:' + items[i]) + console.error(error) } }