mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor(Attachment): Merge MessageAttachment with Attachment (#1894)
* refactor(Attachment): Merge MessageAttachment with Attachment * refactor(Attachment): Rename setup to _patch for consistency * refactor(MessageAttachment): Global rename of Attachment class
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const Attachment = require('./Attachment');
|
||||
const MessageAttachment = require('./MessageAttachment');
|
||||
const Util = require('../util/Util');
|
||||
const { RangeError } = require('../errors');
|
||||
|
||||
@@ -135,10 +135,10 @@ class MessageEmbed {
|
||||
/**
|
||||
* The files of this embed
|
||||
* @type {?Object}
|
||||
* @property {Array<FileOptions|string|Attachment>} files Files to attach
|
||||
* @property {Array<FileOptions|string|MessageAttachment>} files Files to attach
|
||||
*/
|
||||
if (data.files) {
|
||||
for (let file of data.files) if (file instanceof Attachment) file = file.file;
|
||||
for (let file of data.files) if (file instanceof MessageAttachment) file = file.file;
|
||||
} else { data.files = null; }
|
||||
}
|
||||
|
||||
@@ -189,14 +189,14 @@ class MessageEmbed {
|
||||
/**
|
||||
* 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 {Array<FileOptions|string|Attachment>} files Files to attach
|
||||
* @param {Array<FileOptions|string|MessageAttachment>} files Files to attach
|
||||
* @returns {MessageEmbed}
|
||||
*/
|
||||
attachFiles(files) {
|
||||
if (this.files) this.files = this.files.concat(files);
|
||||
else this.files = files;
|
||||
for (let file of files) {
|
||||
if (file instanceof Attachment) file = file.file;
|
||||
if (file instanceof MessageAttachment) file = file.file;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user