mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 13:03:31 +01:00
backport: RichEmbed#attachFiles
This commit is contained in:
@@ -72,6 +72,12 @@ class RichEmbed {
|
|||||||
* @type {FileOptions|string|Attachment}
|
* @type {FileOptions|string|Attachment}
|
||||||
*/
|
*/
|
||||||
this.file = data.file;
|
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;
|
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.
|
* Transforms the embed object to be processed.
|
||||||
* @returns {Object} The raw data of this embed
|
* @returns {Object} The raw data of this embed
|
||||||
|
|||||||
@@ -125,9 +125,15 @@ class TextBasedChannel {
|
|||||||
}
|
}
|
||||||
options.reply = reply;
|
options.reply = reply;
|
||||||
|
|
||||||
if (options.embed && options.embed.file) {
|
if (options.embed) {
|
||||||
if (options.files) options.files.push(options.embed.file);
|
if (options.embed.file) {
|
||||||
else options.files = [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) {
|
if (options.file) {
|
||||||
|
|||||||
Reference in New Issue
Block a user