From 1d4d7d2f9296b6905d89ace8c6ca33eebb632dda Mon Sep 17 00:00:00 2001 From: CBenni Date: Sun, 11 Feb 2018 00:30:40 +0100 Subject: [PATCH] Added some logging for failed message sends --- .eslintrc.json | 5 +++-- imageex.js | 2 +- index.js | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 4105463..b783ac0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,7 +18,8 @@ "no-plusplus": "off", "no-bitwise": "off", "no-continue": "off", - "no-unused-expressions": "off", + "no-unused-expressions": "off", + "no-console": "off", "arrow-parens": [ 2, "as-needed" @@ -46,4 +47,4 @@ } ] } -} \ No newline at end of file +} diff --git a/imageex.js b/imageex.js index 851a551..8195641 100644 --- a/imageex.js +++ b/imageex.js @@ -38,7 +38,7 @@ function _drawImage(ctx, img, x, y, args = {}) { } if (args.attributes) { _.each(args.attributes, (val, prop) => { - console.log(`Setting ${prop } to ${val}`); + console.log(`Setting ${prop} to ${val}`); ctx[prop] = val; }); } diff --git a/index.js b/index.js index c452854..e7e8d32 100644 --- a/index.js +++ b/index.js @@ -155,8 +155,8 @@ app.get('/debug/frame/', async (req, res) => { app.get('/:templateName/', async (req, res) => { if (!templates[req.params.templateName]) return res.status(404).end(); try { - if(!/^https?:/.test(req.query.url)) { - return res.status(400).end("Invalid url!") + if (!/^https?:/.test(req.query.url)) { + return res.status(400).end('Invalid url!'); } const img = new ImageEx(req.query.url); const canvas = render(templates[req.params.templateName], await img.loaded); @@ -181,8 +181,8 @@ const client = new Discord.Client({ // manage roles permission is required const invitelink = `https://discordapp.com/oauth2/authorize?client_id=${ config.discord.client_id}&scope=bot&permissions=0`; -const authlink = `https://discordapp.com/oauth2/authorize?client_id=${ - config.discord.client_id}&scope=email`; +/* const authlink = `https://discordapp.com/oauth2/authorize?client_id=${ + config.discord.client_id}&scope=email`; */ console.log(`Bot invite link: ${invitelink}`); client.login(config.discord.token).catch(error => { @@ -255,7 +255,8 @@ const otherCommands = { client.on('message', async message => { - console.log(`[${message.guild.name} - ${message.channel.name}] ${message.author.username}#${message.author.discriminator}: ${message.cleanContent}`); + console.log(`[${message.guild.name} - ${message.channel.name}] ${message.author.username}` + + `#${message.author.discriminator}: ${message.cleanContent}`); let commandParsed = /^([/\\])(\w+)\b/.exec(message.cleanContent); if (commandParsed) { @@ -301,7 +302,12 @@ client.on('message', async message => { { attachment, name: `${name}.${emoji.ext}` } ] }; - await message.channel.send('', messageOptions); + console.log('Sending message with result:', result); + await message.channel.send('', messageOptions).then(() => { + console.log('Message sent!'); + }).catch(err => { + console.error('Message sending failed:', err); + }); } } } catch (err) {