mirror of
https://github.com/danbulant/discord.js
synced 2026-07-08 20:51:14 +00:00
backport: RichEmbed#attachFiles
This commit is contained in:
parent
4a9c2f8884
commit
b63948e14e
2 changed files with 27 additions and 3 deletions
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue