From ffc51c5503f4ff65b649876980c4906f88bfcf02 Mon Sep 17 00:00:00 2001 From: Supositware Date: Tue, 4 Apr 2023 00:26:52 +0200 Subject: [PATCH] Load commands async --- index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index d52769e..0e2cacb 100644 --- a/index.js +++ b/index.js @@ -18,15 +18,19 @@ const client = new Client({ // Load commands client.commands = new Collection(); -const categoryPath = fs.readdirSync(`${__dirname}/commands`); -categoryPath.forEach(category => { - loadCommandFromDir(category); +fs.readdir(`${__dirname}/commands`, (err, categoryPath) => { + if (err) { + return console.error(err); + } + categoryPath.forEach(category => { + loadCommandFromDir(category); + }); }); // Load events -await loadEventFromDir('client', client); +loadEventFromDir('client', client); if (NODE_ENV !== 'development') { - await loadEventFromDir('process', process); + loadEventFromDir('process', process); } client.login(token); @@ -60,4 +64,4 @@ async function loadEventFromDir(dir, listener) { listener.on(event.name, (...args) => event.execute(...args, client)); } } -} \ No newline at end of file +}