From b63948e14e8cf897b5f46b166a1913954eafc381 Mon Sep 17 00:00:00 2001 From: Lewdcario Date: Thu, 2 Aug 2018 15:06:27 -0600 Subject: [PATCH] backport: RichEmbed#attachFiles --- src/structures/RichEmbed.js | 18 ++++++++++++++++++ src/structures/interfaces/TextBasedChannel.js | 12 +++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/structures/RichEmbed.js b/src/structures/RichEmbed.js index af68bde19..1ebc62328 100644 --- a/src/structures/RichEmbed.js +++ b/src/structures/RichEmbed.js @@ -72,6 +72,12 @@ class RichEmbed { * @type {FileOptions|string|Attachment} */ this.file = data.file; + + /** + * The files to upload alongside this Embed + * @type {Array} + */ + this.files = []; } /** @@ -216,6 +222,18 @@ class RichEmbed { return this; } + /** + * Sets the files to upload alongside the embed. A 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 {RichEmbed} + */ + attachFiles(files) { + files = files.map(file => file instanceof Attachment ? file.file : file); + this.files = this.files.concat(files); + return this; + } + /** * Transforms the embed object to be processed. * @returns {Object} The raw data of this embed diff --git a/src/structures/interfaces/TextBasedChannel.js b/src/structures/interfaces/TextBasedChannel.js index e3ee25018..42c818366 100644 --- a/src/structures/interfaces/TextBasedChannel.js +++ b/src/structures/interfaces/TextBasedChannel.js @@ -125,9 +125,15 @@ class TextBasedChannel { } options.reply = reply; - if (options.embed && options.embed.file) { - if (options.files) options.files.push(options.embed.file); - else options.files = [options.embed.file]; + if (options.embed) { + if (options.embed.file) { + if (options.files) options.files.push(options.embed.file); + else options.files = [options.embed.file]; + } + if (options.embed.files) { + if (options.files) options.files = options.files.concat(options.embed.files); + else options.files = options.embed.files; + } } if (options.file) {