From 2f0cdc6b9ae0915d2552ce6bddc655f426cd7869 Mon Sep 17 00:00:00 2001 From: NoLogicAlan Date: Tue, 5 May 2026 21:22:35 +0300 Subject: [PATCH] filter workss --- package.json | 2 +- src/Player.mjs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 61a0e93..ed2570d 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "genius-lyrics": "^4.4.3", "moonlink.js": "^5.2.0", "mysql": "^2.18.1", - "revoice.js": "^0.2.1694", + "revoice.js": "^0.2.1696", "util": "^0.12.5", "ws": "^8.19.0" }, diff --git a/src/Player.mjs b/src/Player.mjs index 97eb8d7..d3133d7 100644 --- a/src/Player.mjs +++ b/src/Player.mjs @@ -612,8 +612,8 @@ export default class Player extends EventEmitter { const entries = Array.isArray(voiceStates) ? voiceStates : typeof voiceStates.values === "function" - ? voiceStates.values() - : Object.values(voiceStates); + ? voiceStates.values() + : Object.values(voiceStates); for (const state of entries) { const stateChannelId = String(state?.channelId ?? state?.channel_id ?? "").replace(/\D/g, ""); if (stateChannelId === cleanChan) { @@ -1480,7 +1480,13 @@ export default class Player extends EventEmitter { // Restart the current stream so the loadstream URL picks up the new filters. // The PATCH only updates NodeLink's player state — it does NOT modify the // currently-streaming PCM pipe. Without restarting, the audio won't change. - if (current?.encoded && this.connection && !this.leaving && !this._streamingStopped) { + // + // Guard: only restart if we're mid-playback (startedPlaying is set) AND + // _doPlayNext is NOT in progress. When _doPlayNext calls applyFilter() + // before starting a new track, startedPlaying hasn't been set yet and + // _doPlayNext itself handles the stream — firing _replayWithFilters here + // would cause the same song to play twice simultaneously. + if (current?.encoded && this.connection && !this.leaving && !this._streamingStopped && this.startedPlaying && !this._playingNext) { const elapsed = this.startedPlaying ? (Date.now() - this.startedPlaying) : 0; const positionMs = Math.max(0, elapsed); logger.player(`[Player] Filter applied — restarting stream from ${positionMs}ms`);