mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Set bitrate for voice channels support (#363)
* Set bitrate for voice channels * Docs for bitrate settings and values
This commit is contained in:
committed by
abalabahaha
parent
fe1d0bb595
commit
bea1663052
@@ -1638,6 +1638,29 @@ var InternalClient = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
//def setChannelBitrate
|
||||
|
||||
InternalClient.prototype.setChannelBitrate = function setChannelBitrate(channel, kbitrate) {
|
||||
var _this42 = this;
|
||||
|
||||
kbitrate = kbitrate || 64; // default 64kbps
|
||||
|
||||
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"));
|
||||
|
||||
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;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//def updateChannel
|
||||
|
||||
InternalClient.prototype.updateChannel = function updateChannel(chann, data) {
|
||||
@@ -1690,7 +1713,7 @@ var InternalClient = (function () {
|
||||
};
|
||||
|
||||
InternalClient.prototype.createWS = function createWS(url) {
|
||||
var _this42 = this;
|
||||
var _this43 = this;
|
||||
|
||||
var self = this;
|
||||
var client = self.client;
|
||||
@@ -1724,14 +1747,14 @@ var InternalClient = (function () {
|
||||
this.websocket.onclose = function (code) {
|
||||
self.websocket = null;
|
||||
self.state = _ConnectionState2["default"].DISCONNECTED;
|
||||
self.disconnected(_this42.client.options.autoReconnect);
|
||||
self.disconnected(_this43.client.options.autoReconnect);
|
||||
};
|
||||
|
||||
this.websocket.onerror = function (e) {
|
||||
client.emit("error", e);
|
||||
self.websocket = null;
|
||||
self.state = _ConnectionState2["default"].DISCONNECTED;
|
||||
self.disconnected(_this42.client.options.autoReconnect);
|
||||
self.disconnected(_this43.client.options.autoReconnect);
|
||||
};
|
||||
|
||||
this.websocket.onmessage = function (e) {
|
||||
@@ -1760,11 +1783,11 @@ var InternalClient = (function () {
|
||||
|
||||
self.user = self.users.add(new _StructuresUser2["default"](data.user, client));
|
||||
|
||||
_this42.forceFetchCount = {};
|
||||
_this42.forceFetchQueue = [];
|
||||
_this42.forceFetchLength = 1;
|
||||
_this42.autoReconnectInterval = 1000;
|
||||
_this42.sessionID = data.session_id;
|
||||
_this43.forceFetchCount = {};
|
||||
_this43.forceFetchQueue = [];
|
||||
_this43.forceFetchLength = 1;
|
||||
_this43.autoReconnectInterval = 1000;
|
||||
_this43.sessionID = data.session_id;
|
||||
|
||||
data.guilds.forEach(function (server) {
|
||||
if (!server.unavailable) {
|
||||
@@ -2207,7 +2230,7 @@ var InternalClient = (function () {
|
||||
data.id = data.id || user.id;
|
||||
data.avatar = data.avatar || user.avatar;
|
||||
data.discriminator = data.discriminator || user.discriminator;
|
||||
_this42.email = data.email || _this42.email;
|
||||
_this43.email = data.email || _this43.email;
|
||||
|
||||
var presenceUser = new _StructuresUser2["default"](data, client);
|
||||
|
||||
@@ -2349,7 +2372,7 @@ var InternalClient = (function () {
|
||||
|
||||
break;
|
||||
case _Constants.PacketType.FRIEND_ADD:
|
||||
if (_this42.user.bot) {
|
||||
if (_this43.user.bot) {
|
||||
return;
|
||||
}
|
||||
if (data.type === 1) {
|
||||
@@ -2380,7 +2403,7 @@ var InternalClient = (function () {
|
||||
}
|
||||
break;
|
||||
case _Constants.PacketType.FRIEND_REMOVE:
|
||||
if (_this42.user.bot) {
|
||||
if (_this43.user.bot) {
|
||||
return;
|
||||
}
|
||||
var user = self.friends.get("id", data.id);
|
||||
|
||||
Reference in New Issue
Block a user