mirror of
https://github.com/danbulant/discord.js
synced 2026-06-09 17:52:55 +00:00
voice: add ability to delete broadcasts
This commit is contained in:
parent
9a092b6e57
commit
6adb0a6609
2 changed files with 12 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue