mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Added setTopic implementation
This commit is contained in:
@@ -729,6 +729,34 @@ var InternalClient = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
//def setTopic
|
||||
|
||||
InternalClient.prototype.setTopic = function setTopic(chann) {
|
||||
var topic = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
||||
|
||||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
||||
self.resolver.resolveChannel(chann).then(next)["catch"](reject);
|
||||
|
||||
function next(channel) {
|
||||
|
||||
request.patch(Endpoints.CHANNEL(channel.id)).set("authorization", self.token).send({
|
||||
name: channel.name,
|
||||
position: 0,
|
||||
topic: topic
|
||||
}).end(function (err, res) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
channel.topic = res.body.topic;
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
InternalClient.prototype.sendWS = function sendWS(object) {
|
||||
if (this.websocket) this.websocket.send(JSON.stringify(object));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user