Load commands async
This commit is contained in:
parent
a0de902935
commit
ffc51c5503
1 changed files with 10 additions and 6 deletions
16
index.js
16
index.js
|
@ -18,15 +18,19 @@ const client = new Client({
|
||||||
// Load commands
|
// Load commands
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
|
|
||||||
const categoryPath = fs.readdirSync(`${__dirname}/commands`);
|
fs.readdir(`${__dirname}/commands`, (err, categoryPath) => {
|
||||||
categoryPath.forEach(category => {
|
if (err) {
|
||||||
loadCommandFromDir(category);
|
return console.error(err);
|
||||||
|
}
|
||||||
|
categoryPath.forEach(category => {
|
||||||
|
loadCommandFromDir(category);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load events
|
// Load events
|
||||||
await loadEventFromDir('client', client);
|
loadEventFromDir('client', client);
|
||||||
if (NODE_ENV !== 'development') {
|
if (NODE_ENV !== 'development') {
|
||||||
await loadEventFromDir('process', process);
|
loadEventFromDir('process', process);
|
||||||
}
|
}
|
||||||
|
|
||||||
client.login(token);
|
client.login(token);
|
||||||
|
@ -60,4 +64,4 @@ async function loadEventFromDir(dir, listener) {
|
||||||
listener.on(event.name, (...args) => event.execute(...args, client));
|
listener.on(event.name, (...args) => event.execute(...args, client));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue