mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
Updated tests and added file sending
This commit is contained in:
@@ -558,15 +558,34 @@ class Client {
|
||||
} else {
|
||||
fstream = file;
|
||||
}
|
||||
|
||||
|
||||
self.resolveDestination(destination).then(send).catch(error);
|
||||
|
||||
function send(destination) {
|
||||
request
|
||||
.post(`${Endpoints.CHANNELS}/${destination}/messages`)
|
||||
.set("authorization", self.token)
|
||||
.attach("file", fstream, fileName)
|
||||
.end(function (err, res) {
|
||||
|
||||
if (err) {
|
||||
error(err);
|
||||
} else {
|
||||
|
||||
var chann = self.getChannel("id", destination);
|
||||
if (chann) {
|
||||
var msg = chann.addMessage(new Message(res.body, chann, [], self.user));
|
||||
callback(null, msg);
|
||||
resolve(msg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function error(err){
|
||||
|
||||
function error(err) {
|
||||
callback(err);
|
||||
reject(err);
|
||||
}
|
||||
@@ -585,7 +604,7 @@ class Client {
|
||||
var mentions = resolveMentions();
|
||||
self.resolveDestination(destination).then(send).catch(error);
|
||||
|
||||
function error(err){
|
||||
function error(err) {
|
||||
callback(err);
|
||||
reject(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user