Fix crash with message edits between bot restarts

master
Dragory 2018-02-18 22:30:10 +02:00
parent e0bd96e959
commit 0a9f26eaff
1 changed files with 2 additions and 4 deletions

View File

@ -76,11 +76,9 @@ bot.on('messageUpdate', async (msg, oldMessage) => {
if (msg.author.bot) return;
if (await blocked.isBlocked(msg.author.id)) return;
let oldContent = oldMessage.content;
const newContent = msg.content;
// Old message content doesn't persist between bot restarts
if (oldContent == null) oldContent = '*Unavailable due to bot restart*';
const oldContent = oldMessage && oldMessage.content || '*Unavailable due to bot restart*';
const newContent = msg.content;
// Ignore bogus edit events with no changes
if (newContent.trim() === oldContent.trim()) return;