Skip to content

Commit

Permalink
feat(Player): make connected property for voice gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
Fab1o0107 committed Dec 26, 2023
1 parent 1ac9a7a commit c6412bf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/guild/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ export class Player extends EventEmitter {
public position = 0;
/** An filters of the player. */
public filters: FilterOptions = {};
/** Whether Lavalink is connected to the voice gateway. */
public connected = false;
/**
* A encoded of the currently playing track.
* @private
Expand Down Expand Up @@ -475,18 +477,20 @@ export class Player extends EventEmitter {
this.volume = player.volume;
this.paused = player.paused;
this.filters = player.filters;
this.connected = player.state.connected;
this._encodedTrack = player.track?.encoded ?? null;
}

/**
* Handle player update data from Lavalink Websocket.
* @internal
*/
public onPlayerUpdate(data: { state: { position: number; ping: number } }): void {
const { position, ping } = data.state;
public onPlayerUpdate(data: { state: { position: number; ping: number; connected: boolean } }): void {
const { position, ping, connected } = data.state;

this.position = position;
this.ping = ping;
this.connected = connected;

this.emit("update", data);
}
Expand Down

0 comments on commit c6412bf

Please sign in to comment.