From 6adb0a6609905318959a51f4e9d16b2c2a503987 Mon Sep 17 00:00:00 2001 From: Amish Shah Date: Sat, 23 Mar 2019 12:52:18 +0000 Subject: [PATCH] voice: add ability to delete broadcasts --- src/client/voice/ClientVoiceManager.js | 1 - src/client/voice/VoiceBroadcast.js | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/client/voice/ClientVoiceManager.js b/src/client/voice/ClientVoiceManager.js index a8bf79924..fa3513643 100644 --- a/src/client/voice/ClientVoiceManager.js +++ b/src/client/voice/ClientVoiceManager.js @@ -8,7 +8,6 @@ const { Error } = require('../../errors'); /** * Manages voice connections for the client - * @private */ class ClientVoiceManager { constructor(client) { diff --git a/src/client/voice/VoiceBroadcast.js b/src/client/voice/VoiceBroadcast.js index 6cb2bcd14..5446b46cc 100644 --- a/src/client/voice/VoiceBroadcast.js +++ b/src/client/voice/VoiceBroadcast.js @@ -61,6 +61,16 @@ class VoiceBroadcast extends EventEmitter { */ play() { return null; } + + /** + * Ends the broadcast, unsubscribing all subscribed channels and deleting the broadcast + */ + end() { + for (const dispatcher of this.dispatchers) this.delete(dispatcher); + const index = this.client.voice.broadcasts.indexOf(this); + if (index !== -1) this.client.voice.broadcasts.splice(index, 1); + } + add(dispatcher) { const index = this.dispatchers.indexOf(dispatcher); if (index === -1) { @@ -79,6 +89,8 @@ class VoiceBroadcast extends EventEmitter { delete(dispatcher) { const index = this.dispatchers.indexOf(dispatcher); if (index !== -1) { + this.dispatchers.splice(index, 1); + dispatcher.destroy(); /** * Emitted whenever a stream dispatcher unsubscribes to the broadcast. * @event VoiceBroadcast#unsubscribe