Fixed typing and added createChannel

This commit is contained in:
hydrabolt
2015-11-02 17:14:04 +00:00
parent 576715f531
commit 25f0408fae
6 changed files with 164 additions and 48 deletions

View File

@@ -251,6 +251,8 @@ var Client = (function (_EventEmitter) {
});
};
// def leaveServer
Client.prototype.leaveServer = function leaveServer(server) {
var callback = arguments.length <= 1 || arguments[1] === undefined ? function (err) {} : arguments[1];
@@ -265,6 +267,26 @@ var Client = (function (_EventEmitter) {
});
};
// def createChannel
Client.prototype.createChannel = function createChannel(server, name) {
var type = arguments.length <= 2 || arguments[2] === undefined ? "text" : arguments[2];
var callback = arguments.length <= 3 || arguments[3] === undefined ? function (err, channel) {} : arguments[3];
var self = this;
return new Promise(function (resolve, reject) {
if (typeof type === "function") {
// options is the callback
callback = type;
}
self.internal.createChannel(server, name, type).then(function (channel) {
callback(channel);resolve(channel);
})["catch"](function (e) {
callback(e);reject(e);
});
});
};
return Client;
})(EventEmitter);