mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +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 {string} value The value of this field
|
||||||
* @property {boolean} inline If this field will be displayed inline
|
* @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)
|
* The thumbnail of this embed (if there is one)
|
||||||
@@ -138,8 +138,13 @@ class MessageEmbed {
|
|||||||
* @property {Array<FileOptions|string|MessageAttachment>} files Files to attach
|
* @property {Array<FileOptions|string|MessageAttachment>} files Files to attach
|
||||||
*/
|
*/
|
||||||
if (data.files) {
|
if (data.files) {
|
||||||
for (let file of data.files) if (file instanceof MessageAttachment) file = file.file;
|
this.files = data.files.map(file => {
|
||||||
} else { data.files = null; }
|
if (file instanceof MessageAttachment) {
|
||||||
|
return typeof file.file === 'string' ? file.file : Util.cloneObject(file.file);
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user