mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
Added filenamesand fixed sendMessage error handling
This commit is contained in:
@@ -532,7 +532,8 @@ var Client = (function () {
|
||||
}, {
|
||||
key: "sendFile",
|
||||
value: function sendFile(destination, file) {
|
||||
var callback = arguments.length <= 2 || arguments[2] === undefined ? function (err, msg) {} : arguments[2];
|
||||
var fileName = arguments.length <= 2 || arguments[2] === undefined ? "image.png" : arguments[2];
|
||||
var callback = arguments.length <= 3 || arguments[3] === undefined ? function (err, msg) {} : arguments[3];
|
||||
|
||||
var self = this;
|
||||
|
||||
@@ -542,6 +543,7 @@ var Client = (function () {
|
||||
|
||||
if (typeof file === "string" || file instanceof String) {
|
||||
fstream = fs.createReadStream(file);
|
||||
fileName = file;
|
||||
} else {
|
||||
fstream = file;
|
||||
}
|
||||
@@ -570,7 +572,12 @@ var Client = (function () {
|
||||
|
||||
message = premessage + resolveMessage(message);
|
||||
var mentions = resolveMentions();
|
||||
self.resolveDestination(destination).then(send)["catch"](reject);
|
||||
self.resolveDestination(destination).then(send)["catch"](error);
|
||||
|
||||
function error(err) {
|
||||
callback(err);
|
||||
reject(err);
|
||||
}
|
||||
|
||||
function send(destination) {
|
||||
|
||||
|
||||
@@ -544,7 +544,7 @@ class Client {
|
||||
|
||||
}
|
||||
|
||||
sendFile(destination, file, callback = function (err, msg) { }) {
|
||||
sendFile(destination, file, fileName = "image.png", callback = function (err, msg) { }) {
|
||||
|
||||
var self = this;
|
||||
|
||||
@@ -554,6 +554,7 @@ class Client {
|
||||
|
||||
if (typeof file === "string" || file instanceof String) {
|
||||
fstream = fs.createReadStream(file);
|
||||
fileName = file;
|
||||
} else {
|
||||
fstream = file;
|
||||
}
|
||||
@@ -582,7 +583,12 @@ class Client {
|
||||
|
||||
message = premessage + resolveMessage(message);
|
||||
var mentions = resolveMentions();
|
||||
self.resolveDestination(destination).then(send).catch(reject);
|
||||
self.resolveDestination(destination).then(send).catch(error);
|
||||
|
||||
function error(err){
|
||||
callback(err);
|
||||
reject(err);
|
||||
}
|
||||
|
||||
function send(destination) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user