From 27d525c155202790c64414da66c4c9f389515a14 Mon Sep 17 00:00:00 2001 From: Dragory Date: Thu, 2 Aug 2018 02:28:52 +0300 Subject: [PATCH] Add some safeguards against messages without an author --- src/plugins/Censor.ts | 2 +- src/plugins/Logs.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/Censor.ts b/src/plugins/Censor.ts index 2eeba1ca..05c7bc17 100644 --- a/src/plugins/Censor.ts +++ b/src/plugins/Censor.ts @@ -63,7 +63,7 @@ export class CensorPlugin extends Plugin { } async applyFiltersToMsg(msg: Message) { - if (msg.author.bot) return; + if (!msg.author || msg.author.bot) return; if (msg.type !== 0) return; if (!msg.content) return; diff --git a/src/plugins/Logs.ts b/src/plugins/Logs.ts index f62df442..25a0d410 100644 --- a/src/plugins/Logs.ts +++ b/src/plugins/Logs.ts @@ -235,13 +235,14 @@ export class LogsPlugin extends Plugin { @d.event("messageUpdate") onMessageUpdate(msg: Message, oldMsg: Message) { + if (!msg.author) return; if (oldMsg && msg.content === oldMsg.content) return; if (msg.type !== 0) return; this.serverLogs.log(LogType.MESSAGE_EDIT, { member: stripObjectToScalars(msg.member, ["user"]), channel: stripObjectToScalars(msg.channel), - before: oldMsg ? (oldMsg.cleanContent || oldMsg.content || "") : "Unavailable due to restart", + before: oldMsg ? oldMsg.cleanContent || oldMsg.content || "" : "Unavailable due to restart", after: msg.cleanContent || msg.content || "" }); }