This commit is contained in:
NoLogicAlan committed 2026-05-14 17:04:20 +03:00
1 parent 4a62defe1b
commit fab2d51681
2 files changed
+10 -7

No files matched your search

+9 -6
View File
@@ -1412,8 +1412,9 @@ export default class Player extends EventEmitter {
return leftCleanly;
}
destroy() {
destroy(options = {}) {
if (this._destroyed) return;
const skipDisconnect = options?.disconnect === false;
this._destroyed = true;
try {
@@ -1445,11 +1446,13 @@ export default class Player extends EventEmitter {
this._stopMediaPlayer().catch(() => {}).then(() => {
if (connToDestroy) {
try { connToDestroy.removeAllListeners?.(); } catch (_) {}
const disconnectPromise = connToDestroy.disconnect?.();
if (disconnectPromise instanceof Promise) {
disconnectPromise.catch((err) => {
logger.error("[Player] Deferred disconnect failed:", err.message);
});
if (!skipDisconnect) {
const disconnectPromise = connToDestroy.disconnect?.();
if (disconnectPromise instanceof Promise) {
disconnectPromise.catch((err) => {
logger.error("[Player] Deferred disconnect failed:", err.message);
});
}
}
}
});