From 4f130a1a58d2447e8b38f4c08bdff661870f8967 Mon Sep 17 00:00:00 2001 From: Hyper-Coder Date: Tue, 30 Aug 2016 04:43:03 -0400 Subject: [PATCH] Fixed sendFile (#565) https://images.typicalbot.com/i/57c4dcc5d74b7.png --- src/structures/interface/TextBasedChannel.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/structures/interface/TextBasedChannel.js b/src/structures/interface/TextBasedChannel.js index c83817015..01a52a04e 100644 --- a/src/structures/interface/TextBasedChannel.js +++ b/src/structures/interface/TextBasedChannel.js @@ -1,5 +1,6 @@ const Collection = require('../../util/Collection'); const Message = require('../Message'); +const path = require('path'); /** * Interface for classes that have text-channel-like features @@ -74,7 +75,16 @@ class TextBasedChannel { * @param {String} [fileName="file.jpg"] The name and extension of the file * @returns {Promise} */ - sendFile(attachment, fileName = 'file.jpg') { + sendFile(attachment, fileName) { + if (!fileName) { + if (attachment instanceof String || typeof attachment === 'string') { + fileName = path.basename(attachment); + } else if (attachment && attachment.path) { + fileName = path.basename(attachment.path); + } else { + fileName = 'file.jpg'; + } + } return new Promise((resolve, reject) => { this.client.resolver.resolveFile(attachment) .then(file => {