fix/feat(MessageEmbed): deep copy fields and fix files when passed into constructor (#1864)

This commit is contained in:
Drahcirius
2017-09-09 17:43:13 -04:00
committed by Crawl
parent c523e224d7
commit 63f6247ce5

View File

@@ -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;
});
}
} }
/** /**