mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
update attachment & docs (#1815)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user