mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
Added error resolving
This commit is contained in:
@@ -545,6 +545,17 @@ var Client = (function () {
|
|||||||
} else {
|
} else {
|
||||||
fstream = file;
|
fstream = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.resolveDestination(destination).then(send)["catch"](error);
|
||||||
|
|
||||||
|
function send(destination) {
|
||||||
|
request.post(Endpoints.CHANNELS + "/" + destination + "/messages");
|
||||||
|
}
|
||||||
|
|
||||||
|
function error(err) {
|
||||||
|
callback(err);
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -545,23 +545,33 @@ class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendFile(destination, file, callback = function (err, msg) { }) {
|
sendFile(destination, file, callback = function (err, msg) { }) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
return new Promise(function(resolve, reject){
|
return new Promise(function (resolve, reject) {
|
||||||
|
|
||||||
var fstream;
|
var fstream;
|
||||||
|
|
||||||
if(typeof file === "string" || file instanceof String){
|
if (typeof file === "string" || file instanceof String) {
|
||||||
fstream = fs.createReadStream(file);
|
fstream = fs.createReadStream(file);
|
||||||
}else{
|
} else {
|
||||||
fstream = file;
|
fstream = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.resolveDestination(destination).then(send).catch(error);
|
||||||
|
|
||||||
|
function send(destination) {
|
||||||
|
request
|
||||||
|
.post(`${Endpoints.CHANNELS}/${destination}/messages`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function error(err){
|
||||||
|
callback(err);
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(destination, message, callback = function (err, msg) { }, premessage = "") {
|
sendMessage(destination, message, callback = function (err, msg) { }, premessage = "") {
|
||||||
|
|||||||
Reference in New Issue
Block a user