3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Add some safeguards against messages without an author

This commit is contained in:
Dragory 2018-08-02 02:28:52 +03:00
parent c4523ddc32
commit 27d525c155
2 changed files with 3 additions and 2 deletions

View file

@ -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;

View file

@ -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 || ""
});
}