update attachment & docs (#1815)

This commit is contained in:
Isabella
2017-08-21 16:11:58 -05:00
committed by Crawl
parent 0c0ec72cb8
commit 4520c801d3
4 changed files with 23 additions and 32 deletions

View File

@@ -1,10 +1,13 @@
/**
* Represents an attachment in a message.
* @param {BufferResolvable|Stream} file The file
* @param {string} [name] The name of the file, if any
*/
class Attachment {
constructor(file, name) {
this.file = null;
this._attach(file, name);
if (name) this.setAttachment(file, name);
else this._attach(file);
}
/**
@@ -42,7 +45,7 @@ class Attachment {
* @returns {Attachment} This attachment
*/
setFile(attachment) {
this.file.attachment = attachment;
this.file = { attachment };
return this;
}
@@ -63,10 +66,8 @@ class Attachment {
* @private
*/
_attach(file, name) {
if (file) {
if (typeof file === 'string') this.file = file;
else this.setAttachment(file, name);
}
if (typeof file === 'string') this.file = file;
else this.setAttachment(file, name);
}
}

View File

@@ -94,7 +94,7 @@ class Webhook {
/**
* Send a message with this webhook.
* @param {StringResolvable} [content] The content to send
* @param {WebhookMessageOptions} [options={}] The options to provide
* @param {WebhookMessageOptions|MessageEmbed|Attachment|Attachment[]} [options={}] The options to provide
* @returns {Promise<Message|Object>}
* @example
* // Send a message

View File

@@ -66,7 +66,7 @@ class TextBasedChannel {
/**
* Send a message to this channel.
* @param {StringResolvable} [content] Text for the message
* @param {MessageOptions} [options={}] Options for the message
* @param {MessageOptions|MessageEmbed|Attachment|Attachment[]} [options={}] Options for the message
* @returns {Promise<Message|Message[]>}
* @example
* // Send a message