mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03: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,
|
proxyIconURL: data.footer.proxyIconURL || data.footer.proxy_icon_url,
|
||||||
} : null;
|
} : null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The files of this embed
|
||||||
|
* @type {Array<FileOptions|string|MessageAttachment>}
|
||||||
|
*/
|
||||||
|
this.files = [];
|
||||||
|
|
||||||
if (data.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 => {
|
this.files = data.files.map(file => {
|
||||||
if (file instanceof MessageAttachment) {
|
if (file instanceof MessageAttachment) {
|
||||||
return typeof file.file === 'string' ? file.file : Util.cloneObject(file.file);
|
return typeof file.file === 'string' ? file.file : Util.cloneObject(file.file);
|
||||||
@@ -198,11 +199,8 @@ class MessageEmbed {
|
|||||||
* @returns {MessageEmbed}
|
* @returns {MessageEmbed}
|
||||||
*/
|
*/
|
||||||
attachFiles(files) {
|
attachFiles(files) {
|
||||||
if (this.files) this.files = this.files.concat(files);
|
files = files.map(file => file instanceof MessageAttachment ? file.file : file);
|
||||||
else this.files = files;
|
this.files = this.files.concat(files);
|
||||||
for (let file of files) {
|
|
||||||
if (file instanceof MessageAttachment) file = file.file;
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user