From e3e466d3e56145110ba0cfcba7b3c594267d36fb Mon Sep 17 00:00:00 2001 From: Jan <66554238+vaporox@users.noreply.github.com> Date: Fri, 11 Jun 2021 22:36:31 +0200 Subject: [PATCH] refactor(MessageEmbed): remove files (#5813) * refactor(MessageEmbed): remove files * fix: test --- src/structures/APIMessage.js | 21 +-------------------- src/structures/MessageEmbed.js | 18 ------------------ typings/index.d.ts | 3 --- typings/index.ts | 2 +- 4 files changed, 2 insertions(+), 42 deletions(-) diff --git a/src/structures/APIMessage.js b/src/structures/APIMessage.js index d4f5f6564..9b2faccda 100644 --- a/src/structures/APIMessage.js +++ b/src/structures/APIMessage.js @@ -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; } diff --git a/src/structures/MessageEmbed.js b/src/structures/MessageEmbed.js index dc12fe8f2..71e482a2d 100644 --- a/src/structures/MessageEmbed.js +++ b/src/structures/MessageEmbed.js @@ -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} [files] The files of this embed * @property {Partial} [author] The author of this embed * @property {Partial} [thumbnail] The thumbnail of this embed * @property {Partial} [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} - */ - 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} 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 diff --git a/typings/index.d.ts b/typings/index.d.ts index 92b5bf093..9b5592822 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1366,7 +1366,6 @@ declare module 'discord.js' { public readonly createdAt: Date | null; public description: string | null; public fields: EmbedField[]; - public files: (MessageAttachment | string | FileOptions)[]; public footer: MessageEmbedFooter | null; public readonly hexColor: string | null; public image: MessageEmbedImage | null; @@ -1381,7 +1380,6 @@ declare module 'discord.js' { public readonly video: MessageEmbedVideo | null; public addField(name: string, value: string, inline?: boolean): this; public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this; - public attachFiles(file: (MessageAttachment | FileOptions | string)[]): this; public setAuthor(name: string, iconURL?: string, url?: string): this; public setColor(color: ColorResolvable): this; public setDescription(description: string): this; @@ -3277,7 +3275,6 @@ declare module 'discord.js' { timestamp?: Date | number; color?: ColorResolvable; fields?: EmbedFieldData[]; - files?: (MessageAttachment | string | FileOptions)[]; author?: Partial & { icon_url?: string; proxy_icon_url?: string }; thumbnail?: Partial & { proxy_url?: string }; image?: Partial & { proxy_url?: string }; diff --git a/typings/index.ts b/typings/index.ts index eb80fa3ea..c3a4c21a7 100644 --- a/typings/index.ts +++ b/typings/index.ts @@ -39,7 +39,7 @@ client.on('message', ({ channel }) => { const attachment = new MessageAttachment('file.png'); const embed = new MessageEmbed(); assertIsMessage(channel.send({ files: [attachment] })); - assertIsMessage(channel.send(embed)); + assertIsMessage(channel.send({ embed })); assertIsMessage(channel.send({ embed, files: [attachment] })); assertIsMessageArray(channel.send({ split: true }));