mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
Make sendFile() use original file name by default
This commit is contained in:
@@ -206,10 +206,11 @@ var Client = (function (_EventEmitter) {
|
|||||||
|
|
||||||
// def sendFile
|
// def sendFile
|
||||||
|
|
||||||
Client.prototype.sendFile = function sendFile(where, attachment) {
|
Client.prototype.sendFile = function sendFile(where, attachment, name) {
|
||||||
var name = arguments.length <= 2 || arguments[2] === undefined ? "image.png" : arguments[2];
|
|
||||||
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*err, m*/{} : arguments[3];
|
var callback = arguments.length <= 3 || arguments[3] === undefined ? function () /*err, m*/{} : arguments[3];
|
||||||
|
|
||||||
|
name = name ? name : require('path').basename(attachment);
|
||||||
|
|
||||||
return this.internal.sendFile(where, attachment, name).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.sendFile(where, attachment, name).then(dataCallback(callback), errorCallback(callback));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -568,10 +568,10 @@ var InternalClient = (function () {
|
|||||||
|
|
||||||
// def sendFile
|
// def sendFile
|
||||||
|
|
||||||
InternalClient.prototype.sendFile = function sendFile(where, _file) {
|
InternalClient.prototype.sendFile = function sendFile(where, _file, name) {
|
||||||
var _this14 = this;
|
var _this14 = this;
|
||||||
|
|
||||||
var name = arguments.length <= 2 || arguments[2] === undefined ? "image.png" : arguments[2];
|
name = name ? name : require('path').basename(attachment);
|
||||||
|
|
||||||
return this.resolver.resolveChannel(where).then(function (channel) {
|
return this.resolver.resolveChannel(where).then(function (channel) {
|
||||||
return _this14.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(channel.id), true, null, {
|
return _this14.apiRequest("post", _Constants.Endpoints.CHANNEL_MESSAGES(channel.id), true, null, {
|
||||||
|
|||||||
@@ -190,7 +190,9 @@ export default class Client extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// def sendFile
|
// def sendFile
|
||||||
sendFile(where, attachment, name = "image.png", callback = (/*err, m*/) => { }) {
|
sendFile(where, attachment, name, callback = (/*err, m*/) => { }) {
|
||||||
|
name = name ? name : require('path').basename(attachment);
|
||||||
|
|
||||||
return this.internal.sendFile(where, attachment, name)
|
return this.internal.sendFile(where, attachment, name)
|
||||||
.then(dataCallback(callback), errorCallback(callback));
|
.then(dataCallback(callback), errorCallback(callback));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -460,7 +460,9 @@ export default class InternalClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// def sendFile
|
// def sendFile
|
||||||
sendFile(where, _file, name = "image.png") {
|
sendFile(where, _file, name) {
|
||||||
|
name = name ? name : require('path').basename(attachment);
|
||||||
|
|
||||||
return this.resolver.resolveChannel(where)
|
return this.resolver.resolveChannel(where)
|
||||||
.then(channel =>
|
.then(channel =>
|
||||||
this.apiRequest("post", Endpoints.CHANNEL_MESSAGES(channel.id), true, null, {
|
this.apiRequest("post", Endpoints.CHANNEL_MESSAGES(channel.id), true, null, {
|
||||||
|
|||||||
Reference in New Issue
Block a user