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,5 +1,5 @@
const Mentions = require('./MessageMentions');
const Attachment = require('./MessageAttachment');
const MessageAttachment = require('./MessageAttachment');
const Embed = require('./MessageEmbed');
const ReactionCollector = require('./ReactionCollector');
const ClientApplication = require('./ClientApplication');
@@ -96,7 +96,11 @@ class Message extends Base {
* @type {Collection<Snowflake, MessageAttachment>}
*/
this.attachments = new Collection();
for (const attachment of data.attachments) this.attachments.set(attachment.id, new Attachment(this, attachment));
for (const attachment of data.attachments) {
this.attachments.set(attachment.id, new MessageAttachment(
attachment.url, attachment.filename, attachment
));
}
/**
* The timestamp the message was sent at
@@ -180,7 +184,11 @@ class Message extends Base {
if ('attachments' in data) {
this.attachments = new Collection();
for (const attachment of data.attachments) this.attachments.set(attachment.id, new Attachment(this, attachment));
for (const attachment of data.attachments) {
this.attachments.set(attachment.id, new MessageAttachment(
attachment.url, attachment.filename, attachment
));
}
} else {
this.attachments = new Collection(this.attachments);
}