Added setting of channel topics

This commit is contained in:
hydrabolt
2015-09-27 17:37:46 +01:00
parent 5559809aff
commit 16d2410450
3 changed files with 83 additions and 1 deletions

View File

@@ -1141,6 +1141,42 @@ var Client = (function () {
}
return this.getPMChannel("id", data.id);
}
}, {
key: "setTopic",
value: function setTopic(channel, topic) {
var callback = arguments.length <= 2 || arguments[2] === undefined ? function (err) {} : arguments[2];
var self = this;
return new Promise(function (resolve, reject) {
self.resolveDestination(channel).then(next)["catch"](error);
function error(e) {
callback(e);
reject(e);
}
function next(destination) {
var asChan = self.getChannel("id", destination);
request.patch(Endpoints.CHANNELS + "/" + destination).set("authorization", self.token).send({
name: asChan.name,
position: 0,
topic: topic
}).end(function (err, res) {
if (err) {
error(err);
} else {
asChan.topic = res.body.topic;
resolve();
callback();
}
});
}
});
}
//def addServer
}, {
@@ -1437,7 +1473,7 @@ var Client = (function () {
} else {
channId = destination;
}
if (channId) resolve(channId);
if (channId) resolve(channId);else reject();
});
}
}, {