Fix unknown message error due to failed reaction

This commit is contained in:
1Computer1 2019-09-10 16:30:24 -04:00
parent 36a19c4ba8
commit 5a50b41426

View file

@ -23,20 +23,28 @@ class MessageInvalidListener extends Listener {
let reaction; let reaction;
if (!message.guild || message.channel.permissionsFor(this.client.user).has('ADD_REACTIONS')) { 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())); try {
reaction = await message.react('📝'); 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); 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 (!message.guild || message.channel.permissionsFor(this.client.user).has('ADD_REACTIONS')) {
if (reaction) { try {
reaction.users.remove(); if (reaction) {
} reaction.users.remove();
}
if (ok) { if (ok) {
message.react('✔'); message.react('✔');
} else { } else {
message.react('✖'); message.react('✖');
}
} catch (e) {
// Ignore.
} }
} }