From 019b8a03e4054f559cac23ce73fa119442075732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hor=C3=A1=C4=8Dek?= Date: Thu, 9 Apr 2020 09:06:12 +0200 Subject: [PATCH] use strict + login error handling --- index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 353a155..a78b781 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,8 @@ // Woomy version 2 // Copyright 2020 mudkipscience +'use strict' + // Check node.js version if (Number(process.version.slice(1).split('.')[0]) < 12) { console.log('NodeJS 12.0.0 or higher is required. Please update NodeJS on your system.') @@ -107,10 +109,16 @@ const init = async () => { await client.db.init(client) // Login to Discord + function failedToLogin(err) { + client.logger.error('Failed to login: ' + err); + + process.exit(0); + }; + if (client.devmode !== true) { - client.login(client.config.token) + client.login(client.config.token).catch(failedToLogin) } else { - client.login(client.config.token_dev) + client.login(client.config.token_dev).catch(failedToLogin) } }