mirror of
https://github.com/danbulant/discord.js
synced 2026-07-06 19:50:55 +00:00
Optional sendFile name callback and remove extra logic
This commit is contained in:
parent
47f35a942c
commit
3a8f1ddbf9
2 changed files with 11 additions and 3 deletions
|
|
@ -209,7 +209,11 @@ var Client = (function (_EventEmitter) {
|
||||||
Client.prototype.sendFile = function sendFile(where, attachment, name) {
|
Client.prototype.sendFile = function sendFile(where, attachment, name) {
|
||||||
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);
|
if (typeof name === "function") {
|
||||||
|
// name is the callback
|
||||||
|
callback = name;
|
||||||
|
name = undefined; // Will get resolved into original filename in internal
|
||||||
|
}
|
||||||
|
|
||||||
return this.internal.sendFile(where, attachment, name).then(dataCallback(callback), errorCallback(callback));
|
return this.internal.sendFile(where, attachment, name).then(dataCallback(callback), errorCallback(callback));
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -191,8 +191,12 @@ export default class Client extends EventEmitter {
|
||||||
|
|
||||||
// def sendFile
|
// def sendFile
|
||||||
sendFile(where, attachment, name, callback = (/*err, m*/) => { }) {
|
sendFile(where, attachment, name, callback = (/*err, m*/) => { }) {
|
||||||
name = name ? name : require('path').basename(attachment);
|
if (typeof name === "function") {
|
||||||
|
// name is the callback
|
||||||
|
callback = name;
|
||||||
|
name = undefined; // Will get resolved into original filename in internal
|
||||||
|
}
|
||||||
|
|
||||||
return this.internal.sendFile(where, attachment, name)
|
return this.internal.sendFile(where, attachment, name)
|
||||||
.then(dataCallback(callback), errorCallback(callback));
|
.then(dataCallback(callback), errorCallback(callback));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue