Added deleteChannel implementation

This commit is contained in:
hydrabolt
2015-11-02 17:21:27 +00:00
parent 25f0408fae
commit ff9c9b5647
4 changed files with 82 additions and 1 deletions

View File

@@ -413,6 +413,28 @@ var InternalClient = (function () {
});
};
// def deleteChannel
InternalClient.prototype.deleteChannel = function deleteChannel(_channel) {
var self = this;
return new Promise(function (resolve, reject) {
self.resolver.resolveChannel(_channel).then(next)["catch"](reject);
function next(channel) {
request.del(Endpoints.CHANNEL(channel.id)).set("authorization", self.token).end(function (err, res) {
if (err) {
reject(err);
} else {
channel.server.channels.remove(channel);
self.channels.remove(channel);
resolve();
}
});
}
});
};
InternalClient.prototype.sendWS = function sendWS(object) {
if (this.websocket) this.websocket.send(JSON.stringify(object));
};