mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix/feat(MessageEmbed): deep copy fields and fix files when passed into constructor (#1864)
This commit is contained in:
@@ -54,7 +54,7 @@ class MessageEmbed {
|
||||
* @property {string} value The value of this field
|
||||
* @property {boolean} inline If this field will be displayed inline
|
||||
*/
|
||||
this.fields = data.fields || [];
|
||||
this.fields = data.fields ? data.fields.map(Util.cloneObject) : [];
|
||||
|
||||
/**
|
||||
* The thumbnail of this embed (if there is one)
|
||||
@@ -138,8 +138,13 @@ class MessageEmbed {
|
||||
* @property {Array<FileOptions|string|MessageAttachment>} files Files to attach
|
||||
*/
|
||||
if (data.files) {
|
||||
for (let file of data.files) if (file instanceof MessageAttachment) file = file.file;
|
||||
} else { data.files = null; }
|
||||
this.files = data.files.map(file => {
|
||||
if (file instanceof MessageAttachment) {
|
||||
return typeof file.file === 'string' ? file.file : Util.cloneObject(file.file);
|
||||
}
|
||||
return file;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user