mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 09:33:32 +01:00
VoiceChannel user limit support
This commit is contained in:
@@ -969,6 +969,14 @@ var Client = (function (_EventEmitter) {
|
||||
return this.internal.setChannelPosition(channel, position).then(dataCallback(callback), errorCallback(callback));
|
||||
};
|
||||
|
||||
// def setChannelUserLimit
|
||||
|
||||
Client.prototype.setChannelUserLimit = function setChannelUserLimit(channel, limit) {
|
||||
var callback = arguments.length <= 2 || arguments[2] === undefined ? function () /*err, {}*/{} : arguments[2];
|
||||
|
||||
return this.internal.setChannelUserLimit(channel, limit).then(dataCallback(callback), errorCallback(callback));
|
||||
};
|
||||
|
||||
// def updateChannel
|
||||
|
||||
Client.prototype.updateChannel = function updateChannel(channel, data) {
|
||||
|
||||
@@ -1614,6 +1614,30 @@ var InternalClient = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
// def setChannelUserLimit
|
||||
|
||||
InternalClient.prototype.setChannelUserLimit = function setChannelUserLimit(channel, limit) {
|
||||
var _this41 = this;
|
||||
|
||||
limit = limit || 0;
|
||||
|
||||
if (limit > 99) {
|
||||
return Promise.reject(new Error("User limit cannot be greater than 99"));
|
||||
}
|
||||
|
||||
return this.resolver.resolveChannel(channel).then(function (channel) {
|
||||
if (channel.type !== "voice") {
|
||||
return Promise.reject(new Error("Channel must be a voice channel"));
|
||||
}
|
||||
|
||||
return _this41.apiRequest("patch", _Constants.Endpoints.CHANNEL(channel.id), true, {
|
||||
user_limit: limit
|
||||
}).then(function (res) {
|
||||
return channel.userLimit = limit;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//def updateChannel
|
||||
|
||||
InternalClient.prototype.updateChannel = function updateChannel(chann, data) {
|
||||
@@ -1666,7 +1690,7 @@ var InternalClient = (function () {
|
||||
};
|
||||
|
||||
InternalClient.prototype.createWS = function createWS(url) {
|
||||
var _this41 = this;
|
||||
var _this42 = this;
|
||||
|
||||
var self = this;
|
||||
var client = self.client;
|
||||
@@ -1700,14 +1724,14 @@ var InternalClient = (function () {
|
||||
this.websocket.onclose = function (code) {
|
||||
self.websocket = null;
|
||||
self.state = _ConnectionState2["default"].DISCONNECTED;
|
||||
self.disconnected(_this41.client.options.autoReconnect);
|
||||
self.disconnected(_this42.client.options.autoReconnect);
|
||||
};
|
||||
|
||||
this.websocket.onerror = function (e) {
|
||||
client.emit("error", e);
|
||||
self.websocket = null;
|
||||
self.state = _ConnectionState2["default"].DISCONNECTED;
|
||||
self.disconnected(_this41.client.options.autoReconnect);
|
||||
self.disconnected(_this42.client.options.autoReconnect);
|
||||
};
|
||||
|
||||
this.websocket.onmessage = function (e) {
|
||||
@@ -1736,11 +1760,11 @@ var InternalClient = (function () {
|
||||
|
||||
self.user = self.users.add(new _StructuresUser2["default"](data.user, client));
|
||||
|
||||
_this41.forceFetchCount = {};
|
||||
_this41.forceFetchQueue = [];
|
||||
_this41.forceFetchLength = 1;
|
||||
_this41.autoReconnectInterval = 1000;
|
||||
_this41.sessionID = data.session_id;
|
||||
_this42.forceFetchCount = {};
|
||||
_this42.forceFetchQueue = [];
|
||||
_this42.forceFetchLength = 1;
|
||||
_this42.autoReconnectInterval = 1000;
|
||||
_this42.sessionID = data.session_id;
|
||||
|
||||
data.guilds.forEach(function (server) {
|
||||
if (!server.unavailable) {
|
||||
@@ -2182,7 +2206,7 @@ var InternalClient = (function () {
|
||||
data.id = data.id || user.id;
|
||||
data.avatar = data.avatar || user.avatar;
|
||||
data.discriminator = data.discriminator || user.discriminator;
|
||||
_this41.email = data.email || _this41.email;
|
||||
_this42.email = data.email || _this42.email;
|
||||
|
||||
var presenceUser = new _StructuresUser2["default"](data, client);
|
||||
|
||||
@@ -2324,7 +2348,7 @@ var InternalClient = (function () {
|
||||
|
||||
break;
|
||||
case _Constants.PacketType.FRIEND_ADD:
|
||||
if (_this41.user.bot) {
|
||||
if (_this42.user.bot) {
|
||||
return;
|
||||
}
|
||||
if (data.type === 1) {
|
||||
@@ -2355,7 +2379,7 @@ var InternalClient = (function () {
|
||||
}
|
||||
break;
|
||||
case _Constants.PacketType.FRIEND_REMOVE:
|
||||
if (_this41.user.bot) {
|
||||
if (_this42.user.bot) {
|
||||
return;
|
||||
}
|
||||
var user = self.friends.get("id", data.id);
|
||||
|
||||
Reference in New Issue
Block a user