mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
@@ -1548,7 +1548,11 @@ var InternalClient = (function () {
|
||||
var topic = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
||||
|
||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||
return _this37.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
if (channel.type !== "text") {
|
||||
return Promise.reject(new Error("Channel must be a text channel"));
|
||||
}
|
||||
|
||||
_this37.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
name: channel.name,
|
||||
position: channel.position,
|
||||
topic: topic
|
||||
@@ -1566,10 +1570,12 @@ var InternalClient = (function () {
|
||||
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
||||
|
||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||
return _this38.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
_this38.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
name: name,
|
||||
position: channel.position,
|
||||
topic: channel.topic
|
||||
topic: channel.topic,
|
||||
user_limit: channel.userLimit,
|
||||
bitrate: channel.bitrate
|
||||
}).then(function (res) {
|
||||
return channel.name = res.name;
|
||||
});
|
||||
@@ -1585,7 +1591,11 @@ var InternalClient = (function () {
|
||||
var topic = arguments.length <= 2 || arguments[2] === undefined ? "" : arguments[2];
|
||||
|
||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||
return _this39.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
if (channel.type !== "text") {
|
||||
return Promise.reject(new Error("Channel must be a text channel"));
|
||||
}
|
||||
|
||||
_this39.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
name: name,
|
||||
position: channel.position,
|
||||
topic: topic
|
||||
@@ -1596,7 +1606,7 @@ var InternalClient = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
//def setTopic
|
||||
//def setChannelPosition
|
||||
|
||||
InternalClient.prototype.setChannelPosition = function setChannelPosition(chann) {
|
||||
var _this40 = this;
|
||||
@@ -1604,22 +1614,28 @@ var InternalClient = (function () {
|
||||
var position = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
|
||||
|
||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
||||
return _this40.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
_this40.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
name: channel.name,
|
||||
position: position,
|
||||
topic: channel.topic
|
||||
topic: channel.topic,
|
||||
user_limit: channel.userLimit,
|
||||
bitrate: channel._bitrate
|
||||
}).then(function (res) {
|
||||
return channel.position = res.position;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// def setChannelUserLimit
|
||||
//def setChannelUserLimit
|
||||
|
||||
InternalClient.prototype.setChannelUserLimit = function setChannelUserLimit(channel, limit) {
|
||||
var _this41 = this;
|
||||
|
||||
limit = limit || 0;
|
||||
limit = limit || 0; // default 0 = no limit
|
||||
|
||||
if (limit < 0) {
|
||||
return Promise.reject(new Error("User limit cannot be less than 0"));
|
||||
}
|
||||
|
||||
if (limit > 99) {
|
||||
return Promise.reject(new Error("User limit cannot be greater than 99"));
|
||||
@@ -1631,7 +1647,10 @@ var InternalClient = (function () {
|
||||
}
|
||||
|
||||
return _this41.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
user_limit: limit
|
||||
name: channel.name,
|
||||
position: channel.position,
|
||||
user_limit: limit,
|
||||
bitrate: channel._bitrate
|
||||
}).then(function (res) {
|
||||
return channel.userLimit = limit;
|
||||
});
|
||||
@@ -1645,18 +1664,23 @@ var InternalClient = (function () {
|
||||
|
||||
kbitrate = kbitrate || 64; // default 64kbps
|
||||
|
||||
if (kbitrate < 8 || kbitrate > 96) return Promise.reject(new Error("Bitrate must be between 8-96kbps"));
|
||||
if (kbitrate < 8 || kbitrate > 96) {
|
||||
return Promise.reject(new Error("Bitrate must be between 8-96kbps"));
|
||||
}
|
||||
|
||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||
if (channel.type !== "voice") return Promise.reject(new Error("Channel must be a voice channel"));
|
||||
if (channel.type !== "voice") {
|
||||
return Promise.reject(new Error("Channel must be a voice channel"));
|
||||
}
|
||||
|
||||
return _this42.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
name: channel.name,
|
||||
user_limit: channel.userLimit,
|
||||
position: channel.position,
|
||||
bitrate: kbitrate * 1000 // in bps
|
||||
}).then(function () {
|
||||
return channel.bitrate = kbitrate;
|
||||
}).then(function (res) {
|
||||
channel.bitrate = kbitrate;
|
||||
channel._bitrate = kbitrate * 1000;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user