Fix crash when user edits a DM after the thread is closed

master
Miikka 2018-05-03 14:22:38 +03:00 committed by GitHub
parent 82a89b6e86
commit 777ea2dd2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -110,8 +110,9 @@ bot.on('messageUpdate', async (msg, oldMessage) => {
// 1) Edit in DMs // 1) Edit in DMs
if (msg.channel instanceof Eris.PrivateChannel) { if (msg.channel instanceof Eris.PrivateChannel) {
const thread = await threads.findOpenThreadByUserId(msg.author.id); const thread = await threads.findOpenThreadByUserId(msg.author.id);
const editMessage = utils.disableLinkPreviews(`**The user edited their message:**\n\`B:\` ${oldContent}\n\`A:\` ${newContent}`); if (! thread) return;
const editMessage = utils.disableLinkPreviews(`**The user edited their message:**\n\`B:\` ${oldContent}\n\`A:\` ${newContent}`);
thread.postSystemMessage(editMessage); thread.postSystemMessage(editMessage);
} }