From 5a50b4142689e1263e82a5388cd9b09317b7479d Mon Sep 17 00:00:00 2001 From: 1Computer1 Date: Tue, 10 Sep 2019 16:30:24 -0400 Subject: [PATCH] Fix unknown message error due to failed reaction --- src/listeners/messageInvalid.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/listeners/messageInvalid.js b/src/listeners/messageInvalid.js index 385a91b..fb391dd 100644 --- a/src/listeners/messageInvalid.js +++ b/src/listeners/messageInvalid.js @@ -23,20 +23,28 @@ class MessageInvalidListener extends Listener { let reaction; if (!message.guild || message.channel.permissionsFor(this.client.user).has('ADD_REACTIONS')) { - await Promise.all(message.reactions.filter(r => r.me).map(r => r.users.remove())); - reaction = await message.react('📝'); + try { + await Promise.all(message.reactions.filter(r => r.me).map(r => r.users.remove())); + reaction = await message.react('📝'); + } catch (e) { + // Ignore. + } } const [ok, response] = await this.client.myriad.postEval(parse.language, parse.code); if (!message.guild || message.channel.permissionsFor(this.client.user).has('ADD_REACTIONS')) { - if (reaction) { - reaction.users.remove(); - } + try { + if (reaction) { + reaction.users.remove(); + } - if (ok) { - message.react('✔'); - } else { - message.react('✖'); + if (ok) { + message.react('✔'); + } else { + message.react('✖'); + } + } catch (e) { + // Ignore. } }