Skip to content

Commit

Permalink
fix: resume by library boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
Deivu committed Aug 23, 2024
1 parent d59c5a0 commit c2aa503
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/node/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,20 @@ export class Node extends TypedEventEmitter<NodeEvents> {
this.sessionId = json.sessionId;

const players = [ ...this.manager.players.values() ].filter(player => player.node.name === this.name);
const resumeByLibrary = Boolean(this.initialized && (players.length && this.manager.options.resumeByLibrary));

if (!json.resumed && resumeByLibrary) {
let resumedByLibrary = false;
if (!json.resumed && Boolean(this.initialized && (players.length && this.manager.options.resumeByLibrary))) {
try {
await this.resumePlayers();
resumedByLibrary = true;
} catch (error) {
this.error(error as Error);
}
}

this.state = State.CONNECTED;
this.emit('debug', `[Socket] -> [${this.name}] : Lavalink is ready! | Lavalink resume: ${json.resumed} | Lib resume: ${resumeByLibrary}`);
this.emit('ready', json.resumed, resumeByLibrary);
this.emit('debug', `[Socket] -> [${this.name}] : Lavalink is ready! | Lavalink resume: ${json.resumed} | Lib resume: ${resumedByLibrary}`);
this.emit('ready', json.resumed, resumedByLibrary);

if (this.manager.options.resume) {
await this.rest.updateSession(this.manager.options.resume, this.manager.options.resumeTimeout);
Expand Down

0 comments on commit c2aa503

Please sign in to comment.