use strict + login error handling

This commit is contained in:
Lukáš Horáček 2020-04-09 09:06:12 +02:00
parent 33821715f2
commit 019b8a03e4
No known key found for this signature in database
GPG key ID: E07D6630DBC17195

View file

@ -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)
}
}