Skip to content

Commit

Permalink
Added failsafe if file is not found
Browse files Browse the repository at this point in the history
- Added failsafe if file is not found
  • Loading branch information
Vexify4103 authored and SxMAbel committed Oct 26, 2024
1 parent cca0980 commit 88fb28f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/structures/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ export class Manager extends EventEmitter {

for (const file of playerFiles) {
const filePath = path.join(playerStatesDir, file);

if (!fs.existsSync(filePath)) {
console.warn(`File not found: ${filePath}. Skipping...`);
continue;
}

const data = fs.readFileSync(filePath, "utf-8");
const state = JSON.parse(data);

Expand Down Expand Up @@ -143,11 +149,10 @@ export class Manager extends EventEmitter {
reason: "finished",
};
node.queueEnd(player, state.queue.previous, payload as TrackEndEvent);
} else {
} else {
this.destroy(state.guild);
continue;
}

}
} else {
const currentTrack = state.queue.current;
Expand Down

0 comments on commit 88fb28f

Please sign in to comment.