From 6c7a3f98991599c030f79c4153cc5723f93cbac7 Mon Sep 17 00:00:00 2001 From: Maximilian Walterskirchen Date: Wed, 17 Jun 2020 00:15:19 +0200 Subject: [PATCH] fix: Added check for null in Message constructor (#253) Co-authored-by: Walterskirchen Co-authored-by: Pedro S. Lopez --- src/structures/Message.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index da63b87..8702915 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -64,7 +64,7 @@ class Message extends Base { * ID for the Chat that this message was sent to, except if the message was sent by the current user. * @type {string} */ - this.from = typeof (data.from) === 'object' ? data.from._serialized : data.from; + this.from = (typeof (data.from) === 'object' && data.from !== null) ? data.from._serialized : data.from; /** * ID for who this message is for. @@ -73,13 +73,13 @@ class Message extends Base { * If the message is sent by another user, it will be the ID for the current user. * @type {string} */ - this.to = typeof (data.to) === 'object' ? data.to._serialized : data.to; + this.to = (typeof (data.to) === 'object' && data.to !== null) ? data.to._serialized : data.to; /** * If the message was sent to a group, this field will contain the user that sent the message. * @type {string} */ - this.author = typeof (data.author) === 'object' ? data.author._serialized : data.author; + this.author = (typeof (data.author) === 'object' && data.author !== null) ? data.author._serialized : data.author; /** * Indicates if the message was forwarded