mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
Add content parameter to sendFile() (#664)
* Add content arg to sendFile(). Closes #658. * Shorten this a bit.
This commit is contained in:
committed by
Schuyler Cebulskie
parent
47a164bd36
commit
9888cef486
File diff suppressed because one or more lines are too long
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user