backport: RichEmbed#attachFiles

This commit is contained in:
Lewdcario
2018-08-02 15:06:27 -06:00
parent 4a9c2f8884
commit b63948e14e
2 changed files with 27 additions and 3 deletions

View File

@@ -72,6 +72,12 @@ class RichEmbed {
* @type {FileOptions|string|Attachment}
*/
this.file = data.file;
/**
* The files to upload alongside this Embed
* @type {Array<FileOptions|string|Attachment>}
*/
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<FileOptions|string|Attachment>} 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

View File

@@ -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) {