fix(MessageEmbed): correct docs, default to array, resolve MessageAttachments (#2492)

* Fix(MessageEmbed): Remove useless for...of & change this.files to be out of the data.files check...

* Requested changes
This commit is contained in:
Jacz
2018-04-24 03:38:56 +10:00
committed by SpaceEEC
parent b186472785
commit e12ab7428f

View File

@@ -132,12 +132,13 @@ class MessageEmbed {
proxyIconURL: data.footer.proxyIconURL || data.footer.proxy_icon_url,
} : null;
/**
* The files of this embed
* @type {Array<FileOptions|string|MessageAttachment>}
*/
this.files = [];
if (data.files) {
/**
* The files of this embed
* @type {?Object}
* @property {Array<FileOptions|string|MessageAttachment>} files Files to attach
*/
this.files = data.files.map(file => {
if (file instanceof MessageAttachment) {
return typeof file.file === 'string' ? file.file : Util.cloneObject(file.file);
@@ -198,11 +199,8 @@ class MessageEmbed {
* @returns {MessageEmbed}
*/
attachFiles(files) {
if (this.files) this.files = this.files.concat(files);
else this.files = files;
for (let file of files) {
if (file instanceof MessageAttachment) file = file.file;
}
files = files.map(file => file instanceof MessageAttachment ? file.file : file);
this.files = this.files.concat(files);
return this;
}