mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
Handle Voice Server Update events
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -10,12 +10,28 @@ class ClientVoiceManager {
|
|||||||
constructor(client) {
|
constructor(client) {
|
||||||
/**
|
/**
|
||||||
* The client that instantiated this voice manager
|
* The client that instantiated this voice manager
|
||||||
|
* @type {Client}
|
||||||
*/
|
*/
|
||||||
this.client = client;
|
this.client = client;
|
||||||
/**
|
/**
|
||||||
* A collection mapping connection IDs to the Connection objects
|
* A collection mapping connection IDs to the Connection objects
|
||||||
|
* @type {Collection<String, VoiceConnection>}
|
||||||
*/
|
*/
|
||||||
this.connections = new Collection();
|
this.connections = new Collection();
|
||||||
|
/**
|
||||||
|
* Pending connection attempts, maps Guild ID to VoiceChannel
|
||||||
|
* @type {Collection<String, VoiceChannel>}
|
||||||
|
*/
|
||||||
|
this.pending = new Collection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the Client receives information about this voice state update.
|
||||||
|
* @param {String} token the token to authorise with
|
||||||
|
* @param {String} endpoint the endpoint to connect to
|
||||||
|
*/
|
||||||
|
_receivedVoiceServer(token, endpoint) {
|
||||||
|
console.log('got', token, endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,6 +58,7 @@ class ClientVoiceManager {
|
|||||||
* @returns {null}
|
* @returns {null}
|
||||||
*/
|
*/
|
||||||
joinChannel(channel) {
|
joinChannel(channel) {
|
||||||
|
this.pending.set(channel.guild.id, channel);
|
||||||
this._sendWSJoin(channel);
|
this._sendWSJoin(channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class WebSocketPacketManager {
|
|||||||
this.register(Constants.WSEvents.MESSAGE_CREATE, 'MessageCreate');
|
this.register(Constants.WSEvents.MESSAGE_CREATE, 'MessageCreate');
|
||||||
this.register(Constants.WSEvents.MESSAGE_DELETE, 'MessageDelete');
|
this.register(Constants.WSEvents.MESSAGE_DELETE, 'MessageDelete');
|
||||||
this.register(Constants.WSEvents.MESSAGE_UPDATE, 'MessageUpdate');
|
this.register(Constants.WSEvents.MESSAGE_UPDATE, 'MessageUpdate');
|
||||||
|
this.register(Constants.WSEvents.VOICE_SERVER_UPDATE, 'VoiceServerUpdate');
|
||||||
}
|
}
|
||||||
|
|
||||||
get client() {
|
get client() {
|
||||||
|
|||||||
24
src/client/websocket/packets/handlers/VoiceServerUpdate.js
Normal file
24
src/client/websocket/packets/handlers/VoiceServerUpdate.js
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
const AbstractHandler = require('./AbstractHandler');
|
||||||
|
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"token": "my_token",
|
||||||
|
"guild_id": "41771983423143937",
|
||||||
|
"endpoint": "smart.loyal.discord.gg"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
class VoiceServerUpdate extends AbstractHandler {
|
||||||
|
|
||||||
|
handle(packet) {
|
||||||
|
const data = packet.d;
|
||||||
|
const client = this.packetManager.client;
|
||||||
|
|
||||||
|
if (client.voice.pending.get(data.guild_id)) {
|
||||||
|
client.voice._receivedVoiceServer(data.token, data.endpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = VoiceServerUpdate;
|
||||||
@@ -178,6 +178,7 @@ exports.WSEvents = {
|
|||||||
VOICE_STATE_UPDATE: 'VOICE_STATE_UPDATE',
|
VOICE_STATE_UPDATE: 'VOICE_STATE_UPDATE',
|
||||||
FRIEND_ADD: 'RELATIONSHIP_ADD',
|
FRIEND_ADD: 'RELATIONSHIP_ADD',
|
||||||
FRIEND_REMOVE: 'RELATIONSHIP_REMOVE',
|
FRIEND_REMOVE: 'RELATIONSHIP_REMOVE',
|
||||||
|
VOICE_SERVER_UPDATE: 'VOICE_SERVER_UPDATE',
|
||||||
};
|
};
|
||||||
|
|
||||||
const PermissionFlags = exports.PermissionFlags = {
|
const PermissionFlags = exports.PermissionFlags = {
|
||||||
|
|||||||
Reference in New Issue
Block a user