Add content parameter to sendFile() (#664)

* Add content arg to sendFile(). Closes #658.

* Shorten this a bit.
This commit is contained in:
Kelvin Wu
2016-09-08 21:55:18 -04:00
committed by Schuyler Cebulskie
parent 47a164bd36
commit 9888cef486
2 changed files with 4 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@@ -68,9 +68,10 @@ class TextBasedChannel {
* Send a file to this channel * Send a file to this channel
* @param {FileResolvable} attachment The file to send * @param {FileResolvable} attachment The file to send
* @param {string} [fileName="file.jpg"] The name and extension of the file * @param {string} [fileName="file.jpg"] The name and extension of the file
* @param {StringResolvable} [content=undefined] Text message to send with the attachment
* @returns {Promise<Message>} * @returns {Promise<Message>}
*/ */
sendFile(attachment, fileName) { sendFile(attachment, fileName, content) {
if (!fileName) { if (!fileName) {
if (typeof attachment === 'string') { if (typeof attachment === 'string') {
fileName = path.basename(attachment); fileName = path.basename(attachment);
@@ -82,7 +83,7 @@ class TextBasedChannel {
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.client.resolver.resolveFile(attachment).then(file => { this.client.resolver.resolveFile(attachment).then(file => {
this.client.rest.methods.sendMessage(this, undefined, false, undefined, false, { this.client.rest.methods.sendMessage(this, content, false, undefined, false, {
file, file,
name: fileName, name: fileName,
}).then(resolve).catch(reject); }).then(resolve).catch(reject);