diff --git a/src/structures/Message.js b/src/structures/Message.js index 630d21e7e..d76da0596 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -98,7 +98,7 @@ class Message extends Base { * A list of embeds in the message - e.g. YouTube Player * @type {MessageEmbed[]} */ - this.embeds = (data.embeds || []).map(e => new Embed(e)); + this.embeds = (data.embeds || []).map(e => new Embed(e, true)); /** * A collection of attachments in the message - e.g. Pictures - mapped by their ID @@ -225,7 +225,7 @@ class Message extends Base { if ('content' in data) this.content = data.content; if ('pinned' in data) this.pinned = data.pinned; if ('tts' in data) this.tts = data.tts; - if ('embeds' in data) this.embeds = data.embeds.map(e => new Embed(e)); + if ('embeds' in data) this.embeds = data.embeds.map(e => new Embed(e, true)); else this.embeds = this.embeds.slice(); if ('attachments' in data) { diff --git a/src/structures/MessageEmbed.js b/src/structures/MessageEmbed.js index eb67b952c..437fd9f76 100644 --- a/src/structures/MessageEmbed.js +++ b/src/structures/MessageEmbed.js @@ -7,11 +7,11 @@ const Util = require('../util/Util'); * Represents an embed in a message (image/video preview, rich embed, etc.) */ class MessageEmbed { - constructor(data = {}) { - this.setup(data); + constructor(data = {}, skipValidation = false) { + this.setup(data, skipValidation); } - setup(data) { + setup(data, skipValidation) { /** * The type of this embed, either: * * `rich` - a rich embed @@ -65,7 +65,10 @@ class MessageEmbed { * The fields of this embed * @type {EmbedField[]} */ - this.fields = data.fields ? this.constructor.normalizeFields(data.fields) : []; + this.fields = []; + if (data.fields) { + this.fields = skipValidation ? data.fields.map(Util.cloneObject) : this.constructor.normalizeFields(data.fields); + } /** * @typedef {Object} MessageEmbedThumbnail