From 5a75ec61f5022e58c76dc2111c914737da3e916c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85dne=20E=2E=20Moldes=C3=A6ter?= Date: Tue, 21 Apr 2020 22:18:44 +0200 Subject: [PATCH] Improved logging --- bot.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bot.js b/bot.js index eb050e1..ea996d5 100644 --- a/bot.js +++ b/bot.js @@ -31,7 +31,7 @@ client.on('ready', () => { logger.info(`Logged in as: ${client.user.tag}`); client.user.setPresence({ activity: { name: 'with dice | /roll' }}) .then(logger.info) - .catch(logger.error); + .catch(er => logger.error(`Encountered error: ${JSON.stringify(er)}`)); }); client.on('message', msg => { @@ -69,9 +69,17 @@ client.on('message', msg => { } } catch (er) { msg.reply('Sorry, something went wrong.') - logger.error(er); + logger.error(`Encountered error: ${JSON.stringify(er)}`); } }); +client.on('warn', warn => { + logger.warn(`Warning: ${JSON.stringify(er)}`); +}); + +client.on('error', er => { + logger.error(`Error event triggered: ${JSON.stringify(er)}`); +}); + var auth = get_auth(); -client.login(auth.token) +client.login(auth.token);