mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
refactor(MessageEmbed): remove files (#5813)
* refactor(MessageEmbed): remove files * fix: test
This commit is contained in:
@@ -223,26 +223,7 @@ class APIMessage {
|
||||
async resolveFiles() {
|
||||
if (this.files) return this;
|
||||
|
||||
const embedLikes = [];
|
||||
if (this.isInteraction || this.isWebhook) {
|
||||
if (this.options.embeds) {
|
||||
embedLikes.push(...this.options.embeds);
|
||||
}
|
||||
} else if (this.options.embed) {
|
||||
embedLikes.push(this.options.embed);
|
||||
}
|
||||
|
||||
const fileLikes = [];
|
||||
if (this.options.files) {
|
||||
fileLikes.push(...this.options.files);
|
||||
}
|
||||
for (const embed of embedLikes) {
|
||||
if (embed.files) {
|
||||
fileLikes.push(...embed.files);
|
||||
}
|
||||
}
|
||||
|
||||
this.files = await Promise.all(fileLikes.map(f => this.constructor.resolveFile(f)));
|
||||
this.files = await Promise.all(this.options.files?.map(file => this.constructor.resolveFile(file)) ?? []);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ class MessageEmbed {
|
||||
* @property {Date|number} [timestamp] The timestamp of this embed
|
||||
* @property {ColorResolvable} [color] The color of this embed
|
||||
* @property {EmbedFieldData[]} [fields] The fields of this embed
|
||||
* @property {Array<FileOptions|string|MessageAttachment>} [files] The files of this embed
|
||||
* @property {Partial<MessageEmbedAuthor>} [author] The author of this embed
|
||||
* @property {Partial<MessageEmbedThumbnail>} [thumbnail] The thumbnail of this embed
|
||||
* @property {Partial<MessageEmbedImage>} [image] The image of this embed
|
||||
@@ -222,12 +221,6 @@ class MessageEmbed {
|
||||
proxyIconURL: data.footer.proxyIconURL || data.footer.proxy_icon_url,
|
||||
}
|
||||
: null;
|
||||
|
||||
/**
|
||||
* The files of this embed
|
||||
* @type {Array<FileOptions|string|MessageAttachment>}
|
||||
*/
|
||||
this.files = data.files || [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,17 +291,6 @@ class MessageEmbed {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file to upload alongside the embed. This file can be accessed via `attachment://fileName.extension` when
|
||||
* setting an embed image or author/footer icons. Multiple files can be attached.
|
||||
* @param {Array<FileOptions|string|MessageAttachment>} files Files to attach
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
attachFiles(files) {
|
||||
this.files = this.files.concat(files);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the author of this embed.
|
||||
* @param {string} name The name of the author
|
||||
|
||||
Reference in New Issue
Block a user