mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
34 lines
946 B
TypeScript
34 lines
946 B
TypeScript
/* eslint-disable @typescript-eslint/dot-notation */
|
|
import type { AudioPlayer } from './AudioPlayer';
|
|
import type { VoiceConnection } from '../VoiceConnection';
|
|
|
|
/**
|
|
* Represents a subscription of a voice connection to an audio player, allowing
|
|
* the audio player to play audio on the voice connection.
|
|
*/
|
|
export class PlayerSubscription {
|
|
/**
|
|
* The voice connection of this subscription.
|
|
*/
|
|
public readonly connection: VoiceConnection;
|
|
|
|
/**
|
|
* The audio player of this subscription.
|
|
*/
|
|
public readonly player: AudioPlayer;
|
|
|
|
public constructor(connection: VoiceConnection, player: AudioPlayer) {
|
|
this.connection = connection;
|
|
this.player = player;
|
|
}
|
|
|
|
/**
|
|
* Unsubscribes the connection from the audio player, meaning that the
|
|
* audio player cannot stream audio to it until a new subscription is made.
|
|
*/
|
|
public unsubscribe() {
|
|
this.connection['onSubscriptionRemoved'](this);
|
|
this.player['unsubscribe'](this);
|
|
}
|
|
}
|