-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Attachment structure * Fix linter issues + @Private * Fixed array sends, also added embed sends * fixed proving path to attachment * fixed incorrect name assumption from path * linting fix * ;) * im really good at this * changes as requested by gus and computer from #1459 * am a dum * update webhook#send * readonly addition to getters * i... uh... oops * farming deez commits * fix webhook split * removed some ugly * removed .every checks
- Loading branch information
Showing
7 changed files
with
199 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Represents an attachment in a message | ||
*/ | ||
class Attachment { | ||
constructor(file, name) { | ||
this.file = null; | ||
this._attach(file, name); | ||
} | ||
|
||
/** | ||
* The name of the file | ||
* @type {?string} | ||
* @readonly | ||
*/ | ||
get name() { | ||
return this.file.name; | ||
} | ||
|
||
/** | ||
* The file | ||
* @type {?BufferResolvable|Stream} | ||
* @readonly | ||
*/ | ||
get attachment() { | ||
return this.file.attachment; | ||
} | ||
|
||
/** | ||
* Set the file of this attachment. | ||
* @param {BufferResolvable|Stream} file The file | ||
* @param {string} name The name of the file | ||
* @returns {Attachment} This attachment | ||
*/ | ||
setAttachment(file, name) { | ||
this.file = { attachment: file, name }; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the file of this attachment. | ||
* @param {BufferResolvable|Stream} attachment The file | ||
* @returns {Attachment} This attachment | ||
*/ | ||
setFile(attachment) { | ||
this.file.attachment = attachment; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the name of this attachment. | ||
* @param {string} name The name of the image | ||
* @returns {Attachment} This attachment | ||
*/ | ||
setName(name) { | ||
this.file.name = name; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the file of this attachment. | ||
* @param {BufferResolvable|Stream} file The file | ||
* @param {string} name The name of the file | ||
* @private | ||
*/ | ||
_attach(file, name) { | ||
if (file) { | ||
if (typeof file === 'string') this.file = file; | ||
else this.setAttachment(file, name); | ||
} | ||
} | ||
} | ||
|
||
module.exports = Attachment; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters