mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
more channel features
This commit is contained in:
@@ -757,6 +757,70 @@ var InternalClient = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
//def setChannelName
|
||||
|
||||
InternalClient.prototype.setChannelName = function setChannelName(chann) {
|
||||
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : 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: name,
|
||||
position: 0,
|
||||
topic: channel.topic
|
||||
}).end(function (err, res) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
channel.name = res.body.name;
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//def setChannelNameAndTopic
|
||||
|
||||
InternalClient.prototype.setChannelNameAndTopic = function setChannelNameAndTopic(chann) {
|
||||
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
||||
var topic = arguments.length <= 2 || arguments[2] === undefined ? "" : arguments[2];
|
||||
|
||||
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: name,
|
||||
position: 0,
|
||||
topic: topic
|
||||
}).end(function (err, res) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
channel.name = res.body.name;
|
||||
channel.topic = res.body.topic;
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//def updateChannel
|
||||
|
||||
InternalClient.prototype.updateChannel = function updateChannel(chann, data) {
|
||||
return this.setChannelNameAndTopic(chann, data.name, data.topic);
|
||||
};
|
||||
|
||||
InternalClient.prototype.sendWS = function sendWS(object) {
|
||||
if (this.websocket) this.websocket.send(JSON.stringify(object));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user