From c40488eb543a8450f2bfc4d2984187ea7b65d67c Mon Sep 17 00:00:00 2001 From: Will Nelson Date: Sat, 24 Mar 2018 17:43:56 -0700 Subject: [PATCH] fix message embed json serialization (#2420) * fix message embed json serialization remove the toJSON method on message embeds so the raw data is exposed for JSON seralization. this removes the hexColor property, but it probably should not have been there in the first place. fixes #2419 * change api transform to tojson --- src/structures/MessageEmbed.js | 7 +------ src/structures/shared/CreateMessage.js | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/structures/MessageEmbed.js b/src/structures/MessageEmbed.js index 82d930eda..5f84563bc 100644 --- a/src/structures/MessageEmbed.js +++ b/src/structures/MessageEmbed.js @@ -302,16 +302,11 @@ class MessageEmbed { return this; } - toJSON() { - return Util.flatten(this, { hexColor: true }); - } - /** * Transforms the embed object to be processed. * @returns {Object} The raw data of this embed - * @private */ - _apiTransform() { + toJSON() { return { title: this.title, type: 'rich', diff --git a/src/structures/shared/CreateMessage.js b/src/structures/shared/CreateMessage.js index 55d779cf5..ea83618ac 100644 --- a/src/structures/shared/CreateMessage.js +++ b/src/structures/shared/CreateMessage.js @@ -71,9 +71,9 @@ module.exports = async function createMessage(channel, options) { else options.files = options.embed.files; } - if (options.embed && webhook) options.embeds = [new Embed(options.embed)._apiTransform()]; - else if (options.embed) options.embed = new Embed(options.embed)._apiTransform(); - else if (options.embeds) options.embeds = options.embeds.map(e => new Embed(e)._apiTransform()); + if (options.embed && webhook) options.embeds = [new Embed(options.embed)]; + else if (options.embed) options.embed = new Embed(options.embed); + else if (options.embeds) options.embeds = options.embeds.map(e => new Embed(e)); let files;