From 6f189cc523679d1dff7430ba136b6621f4a13612 Mon Sep 17 00:00:00 2001 From: "Jonny_Bro (Nikita)" Date: Wed, 15 Mar 2023 23:39:47 +0500 Subject: [PATCH] v5.3.14 Waiting for proper fix... --- package.json | 2 +- src/VoiceInterface/StreamDispatcher.ts | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 45010cb..58dc38f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-player-play-dl", - "version": "5.3.13", + "version": "5.3.14", "description": "Complete framework to facilitate music commands using discord.js and play-dl", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/VoiceInterface/StreamDispatcher.ts b/src/VoiceInterface/StreamDispatcher.ts index d6575e0..37af32c 100644 --- a/src/VoiceInterface/StreamDispatcher.ts +++ b/src/VoiceInterface/StreamDispatcher.ts @@ -9,7 +9,8 @@ import { StreamType, VoiceConnection, VoiceConnectionStatus, - VoiceConnectionDisconnectReason + VoiceConnectionDisconnectReason, + VoiceConnectionState } from "@discordjs/voice"; import { StageChannel, VoiceChannel } from "discord.js"; import { Duplex, Readable } from "stream"; @@ -68,7 +69,20 @@ class StreamDispatcher extends EventEmitter { */ this.paused = false; - this.voiceConnection.on("stateChange", async (_, newState) => { + this.voiceConnection.on("stateChange", async (oldState, newState) => { + // oh no, fix no work + const oldNetworking = Reflect.get(oldState, "networking"); + const newNetworking = Reflect.get(newState, "networking"); + + const networkStateChangeHandler = (_: VoiceConnectionState, newNetworkState: VoiceConnectionState) => { + const newUdp = Reflect.get(newNetworkState, "udp"); + clearInterval(newUdp?.keepAliveInterval); + }; + + oldNetworking?.off("stateChange", networkStateChangeHandler); + newNetworking?.on("stateChange", networkStateChangeHandler); + // temp fix end + if (newState.status === VoiceConnectionStatus.Disconnected) { if (newState.reason === VoiceConnectionDisconnectReason.WebSocketClose && newState.closeCode === 4014) { try {