mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user