mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
voice: add ability to delete broadcasts
This commit is contained in:
@@ -8,7 +8,6 @@ const { Error } = require('../../errors');
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages voice connections for the client
|
* Manages voice connections for the client
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
class ClientVoiceManager {
|
class ClientVoiceManager {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
|
|||||||
@@ -61,6 +61,16 @@ class VoiceBroadcast extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
play() { return null; }
|
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) {
|
add(dispatcher) {
|
||||||
const index = this.dispatchers.indexOf(dispatcher);
|
const index = this.dispatchers.indexOf(dispatcher);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
@@ -79,6 +89,8 @@ class VoiceBroadcast extends EventEmitter {
|
|||||||
delete(dispatcher) {
|
delete(dispatcher) {
|
||||||
const index = this.dispatchers.indexOf(dispatcher);
|
const index = this.dispatchers.indexOf(dispatcher);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
|
this.dispatchers.splice(index, 1);
|
||||||
|
dispatcher.destroy();
|
||||||
/**
|
/**
|
||||||
* Emitted whenever a stream dispatcher unsubscribes to the broadcast.
|
* Emitted whenever a stream dispatcher unsubscribes to the broadcast.
|
||||||
* @event VoiceBroadcast#unsubscribe
|
* @event VoiceBroadcast#unsubscribe
|
||||||
|
|||||||
Reference in New Issue
Block a user