fix(ApiMessage): only pass objects as options directly (#5793)

* fix(ApiMessage): only pass objects as options directly

* refactor: inline if with ternary
This commit is contained in:
ckohen
2021-06-10 00:41:01 -07:00
committed by GitHub
parent 35c2225f50
commit 35781597d0

View File

@@ -320,8 +320,10 @@ class APIMessage {
* @returns {MessageOptions|WebhookMessageOptions}
*/
static create(target, options, extra = {}) {
if (typeof options === 'string') 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 },
);
}
}