error handling for events & commands

This commit is contained in:
Lukáš Horáček 2020-03-31 13:36:17 +02:00
parent a78e759ba9
commit 204977952d
No known key found for this signature in database
GPG key ID: E07D6630DBC17195

View file

@ -61,7 +61,12 @@ client.aliases = new Discord.Collection()
const init = async () => {
// Load events
fs.readdir('./events', (err, files) => {
if (err) {}
if (err) {
client.logger.error('Failed to get files in events directory! ' + err);
return;
};
client.logger.info(`Loading ${files.length} events.`)
files.forEach(file => {
if (!file.endsWith('.js')) {
@ -74,7 +79,12 @@ const init = async () => {
// Load commands
fs.readdir('./commands', (err, files) => {
if (err) {}
if (err) {
client.logger.error('Failed to get files in commands directory! ' + err);
return;
};
client.logger.info(`Loading ${files.length} commands.`)
files.forEach(file => {
if (!file.endsWith('.js')) {