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:
Robin B
2017-09-06 23:12:20 +02:00
committed by Crawl
parent 694f78cd43
commit d6b276bc29
7 changed files with 99 additions and 119 deletions

View File

@@ -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;
}