mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
Add RichEmbed#attachFile (#1202)
* Add RichEmbed#attachFile Mostly for attaching local images that can be accessed within the embed image/author icon/footer icon via `attachment//filename.png` and the like. * Update docstring to reflect valid param types * Update TextBasedChannel.js * Update RichEmbed.js * Update RichEmbed.js
This commit is contained in:
committed by
Schuyler Cebulskie
parent
d4a84915e6
commit
db5259cdf1
@@ -65,6 +65,12 @@ class RichEmbed {
|
|||||||
* @type {Object}
|
* @type {Object}
|
||||||
*/
|
*/
|
||||||
this.footer = data.footer;
|
this.footer = data.footer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File to upload alongside this Embed
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.file = data.file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,6 +197,18 @@ class RichEmbed {
|
|||||||
this.footer = { text, icon_url: icon };
|
this.footer = { text, icon_url: icon };
|
||||||
return this;
|
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. Only one file may be attached.
|
||||||
|
* @param {FileOptions|string} file Local path or URL to the file to attach, or valid FileOptions for a file to attach
|
||||||
|
* @returns {RichEmbed} This embed
|
||||||
|
*/
|
||||||
|
attachFile(file) {
|
||||||
|
if (this.file) throw new RangeError('You may not upload more than one file at once.');
|
||||||
|
this.file = file;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RichEmbed;
|
module.exports = RichEmbed;
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ class TextBasedChannel {
|
|||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.embed && options.embed.file) options.file = options.embed.file;
|
||||||
|
|
||||||
if (options.file) {
|
if (options.file) {
|
||||||
if (typeof options.file === 'string') options.file = { attachment: options.file };
|
if (typeof options.file === 'string') options.file = { attachment: options.file };
|
||||||
if (!options.file.name) {
|
if (!options.file.name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user