Added updateMessage

This commit is contained in:
hydrabolt
2015-10-31 23:23:48 +00:00
parent a333548c00
commit 4b4b7d6a47
8 changed files with 180 additions and 36 deletions

View File

@@ -148,6 +148,8 @@ var Client = (function (_EventEmitter) {
});
};
// def deleteMessage
Client.prototype.deleteMessage = function deleteMessage(msg) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var callback = arguments.length <= 2 || arguments[2] === undefined ? function (e) {} : arguments[2];
@@ -169,6 +171,29 @@ var Client = (function (_EventEmitter) {
});
};
//def updateMessage
Client.prototype.updateMessage = function updateMessage(msg, content) {
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var callback = arguments.length <= 3 || arguments[3] === undefined ? function (err, msg) {} : arguments[3];
var self = this;
return new Promise(function (resolve, reject) {
if (typeof options === "function") {
// options is the callback
callback = options;
}
self.internal.updateMessage(msg, content, options).then(function (msg) {
callback(null, msg);
resolve(msg);
})["catch"](function (e) {
callback(e);
reject(e);
});
});
};
return Client;
})(EventEmitter);