mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
@@ -1548,7 +1548,11 @@ var InternalClient = (function () {
|
|||||||
var topic = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
var topic = arguments.length <= 1 || arguments[1] === undefined ? "" : arguments[1];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
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,
|
name: channel.name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: topic
|
topic: topic
|
||||||
@@ -1566,10 +1570,12 @@ var InternalClient = (function () {
|
|||||||
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
var name = arguments.length <= 1 || arguments[1] === undefined ? "discordjs_is_the_best" : arguments[1];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
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,
|
name: name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: channel.topic
|
topic: channel.topic,
|
||||||
|
user_limit: channel.userLimit,
|
||||||
|
bitrate: channel.bitrate
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
return channel.name = res.name;
|
return channel.name = res.name;
|
||||||
});
|
});
|
||||||
@@ -1585,7 +1591,11 @@ var InternalClient = (function () {
|
|||||||
var topic = arguments.length <= 2 || arguments[2] === undefined ? "" : arguments[2];
|
var topic = arguments.length <= 2 || arguments[2] === undefined ? "" : arguments[2];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
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,
|
name: name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: topic
|
topic: topic
|
||||||
@@ -1596,7 +1606,7 @@ var InternalClient = (function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//def setTopic
|
//def setChannelPosition
|
||||||
|
|
||||||
InternalClient.prototype.setChannelPosition = function setChannelPosition(chann) {
|
InternalClient.prototype.setChannelPosition = function setChannelPosition(chann) {
|
||||||
var _this40 = this;
|
var _this40 = this;
|
||||||
@@ -1604,22 +1614,28 @@ var InternalClient = (function () {
|
|||||||
var position = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
|
var position = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
|
||||||
|
|
||||||
return this.resolver.resolveChannel(chann).then(function (channel) {
|
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,
|
name: channel.name,
|
||||||
position: position,
|
position: position,
|
||||||
topic: channel.topic
|
topic: channel.topic,
|
||||||
|
user_limit: channel.userLimit,
|
||||||
|
bitrate: channel._bitrate
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
return channel.position = res.position;
|
return channel.position = res.position;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// def setChannelUserLimit
|
//def setChannelUserLimit
|
||||||
|
|
||||||
InternalClient.prototype.setChannelUserLimit = function setChannelUserLimit(channel, limit) {
|
InternalClient.prototype.setChannelUserLimit = function setChannelUserLimit(channel, limit) {
|
||||||
var _this41 = this;
|
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) {
|
if (limit > 99) {
|
||||||
return Promise.reject(new Error("User limit cannot be greater than 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, {
|
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) {
|
}).then(function (res) {
|
||||||
return channel.userLimit = limit;
|
return channel.userLimit = limit;
|
||||||
});
|
});
|
||||||
@@ -1645,18 +1664,23 @@ var InternalClient = (function () {
|
|||||||
|
|
||||||
kbitrate = kbitrate || 64; // default 64kbps
|
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) {
|
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, {
|
return _this42.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
user_limit: channel.userLimit,
|
user_limit: channel.userLimit,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
bitrate: kbitrate * 1000 // in bps
|
bitrate: kbitrate * 1000 // in bps
|
||||||
}).then(function () {
|
}).then(function (res) {
|
||||||
return channel.bitrate = kbitrate;
|
channel.bitrate = kbitrate;
|
||||||
|
channel._bitrate = kbitrate * 1000;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ var VoiceChannel = (function (_ServerChannel) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
VoiceChannel.prototype.setUserLimit = function setUserLimit() {
|
VoiceChannel.prototype.setUserLimit = function setUserLimit() {
|
||||||
return this.client.setChannelUserLimit.apply(this.client, [this, arguments]);
|
return this.client.setChannelUserLimit.apply(this.client, _UtilArgumentRegulariser.reg(this, arguments));
|
||||||
};
|
};
|
||||||
|
|
||||||
VoiceChannel.prototype.setBitrate = function setBitrate() {
|
VoiceChannel.prototype.setBitrate = function setBitrate() {
|
||||||
|
|||||||
@@ -1302,33 +1302,43 @@ export default class InternalClient {
|
|||||||
//def setChannelTopic
|
//def setChannelTopic
|
||||||
setChannelTopic(chann, topic = "") {
|
setChannelTopic(chann, topic = "") {
|
||||||
return this.resolver.resolveChannel(chann)
|
return this.resolver.resolveChannel(chann)
|
||||||
.then(channel =>
|
.then(channel => {
|
||||||
|
if (channel.type !== "text") {
|
||||||
|
return Promise.reject(new Error("Channel must be a text channel"));
|
||||||
|
}
|
||||||
|
|
||||||
this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: topic
|
topic: topic
|
||||||
})
|
})
|
||||||
.then(res => channel.topic = res.topic)
|
.then(res => channel.topic = res.topic)
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//def setChannelName
|
//def setChannelName
|
||||||
setChannelName(chann, name = "discordjs_is_the_best") {
|
setChannelName(chann, name = "discordjs_is_the_best") {
|
||||||
return this.resolver.resolveChannel(chann)
|
return this.resolver.resolveChannel(chann)
|
||||||
.then(channel =>
|
.then(channel => {
|
||||||
this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: name,
|
name: name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
topic: channel.topic
|
topic: channel.topic,
|
||||||
|
user_limit: channel.userLimit,
|
||||||
|
bitrate: channel.bitrate
|
||||||
})
|
})
|
||||||
.then(res => channel.name = res.name)
|
.then(res => channel.name = res.name)
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//def setChannelNameAndTopic
|
//def setChannelNameAndTopic
|
||||||
setChannelNameAndTopic(chann, name = "discordjs_is_the_best", topic = "") {
|
setChannelNameAndTopic(chann, name = "discordjs_is_the_best", topic = "") {
|
||||||
return this.resolver.resolveChannel(chann)
|
return this.resolver.resolveChannel(chann)
|
||||||
.then(channel =>
|
.then(channel => {
|
||||||
|
if (channel.type !== "text") {
|
||||||
|
return Promise.reject(new Error("Channel must be a text channel"));
|
||||||
|
}
|
||||||
|
|
||||||
this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: name,
|
name: name,
|
||||||
position: channel.position,
|
position: channel.position,
|
||||||
@@ -1338,25 +1348,31 @@ export default class InternalClient {
|
|||||||
channel.name = res.name;
|
channel.name = res.name;
|
||||||
channel.topic = res.topic;
|
channel.topic = res.topic;
|
||||||
})
|
})
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//def setTopic
|
//def setChannelPosition
|
||||||
setChannelPosition(chann, position = 0) {
|
setChannelPosition(chann, position = 0) {
|
||||||
return this.resolver.resolveChannel(chann)
|
return this.resolver.resolveChannel(chann)
|
||||||
.then(channel =>
|
.then(channel => {
|
||||||
this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
position: position,
|
position: position,
|
||||||
topic: channel.topic
|
topic: channel.topic,
|
||||||
|
user_limit: channel.userLimit,
|
||||||
|
bitrate: channel._bitrate
|
||||||
})
|
})
|
||||||
.then(res => channel.position = res.position)
|
.then(res => channel.position = res.position)
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// def setChannelUserLimit
|
//def setChannelUserLimit
|
||||||
setChannelUserLimit(channel, limit) {
|
setChannelUserLimit(channel, limit) {
|
||||||
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) {
|
if (limit > 99) {
|
||||||
return Promise.reject(new Error("User limit cannot be greater than 99"));
|
return Promise.reject(new Error("User limit cannot be greater than 99"));
|
||||||
@@ -1368,7 +1384,10 @@ export default class InternalClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
return this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
||||||
user_limit: limit
|
name: channel.name,
|
||||||
|
position: channel.position,
|
||||||
|
user_limit: limit,
|
||||||
|
bitrate: channel._bitrate
|
||||||
})
|
})
|
||||||
.then(res => channel.userLimit = limit);
|
.then(res => channel.userLimit = limit);
|
||||||
});
|
});
|
||||||
@@ -1378,12 +1397,14 @@ export default class InternalClient {
|
|||||||
setChannelBitrate(channel, kbitrate) {
|
setChannelBitrate(channel, kbitrate) {
|
||||||
kbitrate = kbitrate || 64; // default 64kbps
|
kbitrate = kbitrate || 64; // default 64kbps
|
||||||
|
|
||||||
if (kbitrate < 8 || kbitrate > 96)
|
if (kbitrate < 8 || kbitrate > 96) {
|
||||||
return Promise.reject(new Error("Bitrate must be between 8-96kbps"));
|
return Promise.reject(new Error("Bitrate must be between 8-96kbps"));
|
||||||
|
}
|
||||||
|
|
||||||
return this.resolver.resolveChannel(channel).then(channel => {
|
return this.resolver.resolveChannel(channel).then(channel => {
|
||||||
if (channel.type !== "voice")
|
if (channel.type !== "voice") {
|
||||||
return Promise.reject(new Error("Channel must be a voice channel"));
|
return Promise.reject(new Error("Channel must be a voice channel"));
|
||||||
|
}
|
||||||
|
|
||||||
return this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
return this.apiRequest("patch", Endpoints.CHANNEL(channel.id), true, {
|
||||||
name: channel.name,
|
name: channel.name,
|
||||||
@@ -1391,7 +1412,10 @@ export default class InternalClient {
|
|||||||
position: channel.position,
|
position: channel.position,
|
||||||
bitrate: kbitrate * 1000 // in bps
|
bitrate: kbitrate * 1000 // in bps
|
||||||
})
|
})
|
||||||
.then(() => channel.bitrate = kbitrate);
|
.then(res => {
|
||||||
|
channel.bitrate = kbitrate;
|
||||||
|
channel._bitrate = kbitrate * 1000;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default class VoiceChannel extends ServerChannel{
|
|||||||
}
|
}
|
||||||
|
|
||||||
setUserLimit() {
|
setUserLimit() {
|
||||||
return this.client.setChannelUserLimit.apply(this.client, [this, arguments]);
|
return this.client.setChannelUserLimit.apply(this.client, reg(this, arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
setBitrate() {
|
setBitrate() {
|
||||||
|
|||||||
Reference in New Issue
Block a user