Updated tests and added file sending

This commit is contained in:
hydrabolt
2015-08-26 14:00:52 +01:00
parent 20b970ee9d
commit 38e81c23c9
4 changed files with 46 additions and 7 deletions

View File

@@ -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);
}