mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
Merge remote-tracking branch 'ntay/sendfile-original-name' into indev
This commit is contained in:
@@ -573,10 +573,19 @@ var InternalClient = (function () {
|
||||
|
||||
// def sendFile
|
||||
|
||||
InternalClient.prototype.sendFile = function sendFile(where, _file) {
|
||||
InternalClient.prototype.sendFile = function sendFile(where, _file, name) {
|
||||
var _this15 = this;
|
||||
|
||||
var name = arguments.length <= 2 || arguments[2] === undefined ? "image.png" : arguments[2];
|
||||
if (!name) {
|
||||
if (_file instanceof String || typeof _file === "string") {
|
||||
name = require("path").basename(attachment);
|
||||
} else if (_file.path) {
|
||||
// fs.createReadStream()'s have .path that give the path. Not sure about other streams though.
|
||||
name = require("path").basename(_file.path);
|
||||
} else {
|
||||
name = "image.png"; // Just have to go with default filenames.
|
||||
}
|
||||
}
|
||||
|
||||
return this.resolver.resolveChannel(where).then(function (channel) {
|
||||
return _this15.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(channel.id), true, null, {
|
||||
|
||||
Reference in New Issue
Block a user