From 21ea082ca73ba915d5ce52e81368bd15bfa7efbf Mon Sep 17 00:00:00 2001 From: ckohen Date: Wed, 9 Jun 2021 16:42:48 -0700 Subject: [PATCH 1/2] fix(ApiMessage): only pass objects as options directly --- src/structures/APIMessage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/APIMessage.js b/src/structures/APIMessage.js index 7f5116c9399e..209b7a64620c 100644 --- a/src/structures/APIMessage.js +++ b/src/structures/APIMessage.js @@ -320,7 +320,7 @@ class APIMessage { * @returns {MessageOptions|WebhookMessageOptions} */ static create(target, options, extra = {}) { - if (typeof options === 'string') return new this(target, { content: options, ...extra }); + if (typeof options !== 'object' || options === null) return new this(target, { content: options, ...extra }); else return new this(target, { ...options, ...extra }); } } From be26e1a1e4cbeb607adf4d90663fb0666a762753 Mon Sep 17 00:00:00 2001 From: ckohen Date: Wed, 9 Jun 2021 22:45:24 -0700 Subject: [PATCH 2/2] refactor: inline if with ternary --- src/structures/APIMessage.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/structures/APIMessage.js b/src/structures/APIMessage.js index 209b7a64620c..d4f5f6564569 100644 --- a/src/structures/APIMessage.js +++ b/src/structures/APIMessage.js @@ -320,8 +320,10 @@ class APIMessage { * @returns {MessageOptions|WebhookMessageOptions} */ static create(target, options, extra = {}) { - if (typeof options !== 'object' || options === null) return new this(target, { content: options, ...extra }); - else return new this(target, { ...options, ...extra }); + return new this( + target, + typeof options !== 'object' || options === null ? { content: options, ...extra } : { ...options, ...extra }, + ); } }