diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2023-03-11 18:54:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-11 18:54:53 -0500 |
| commit | c520d84a0e3755557f0c8bb47d691fd2beb89c26 (patch) | |
| tree | 9cd97ae0de078c4f12b9e840cca527eca3cf3d38 /AudioBackend/VoiceInitialization.js | |
| parent | 4f5a9747dc9b0ce0a9206b311dda3590b179df0b (diff) | |
| download | DLAP-c520d84a0e3755557f0c8bb47d691fd2beb89c26.tar.gz DLAP-c520d84a0e3755557f0c8bb47d691fd2beb89c26.tar.bz2 DLAP-c520d84a0e3755557f0c8bb47d691fd2beb89c26.zip | |
Hopefully fixed an issue that causes the audio to stop in a minute?
Diffstat (limited to 'AudioBackend/VoiceInitialization.js')
| -rw-r--r-- | AudioBackend/VoiceInitialization.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/AudioBackend/VoiceInitialization.js b/AudioBackend/VoiceInitialization.js index ae1241b..4821a5c 100644 --- a/AudioBackend/VoiceInitialization.js +++ b/AudioBackend/VoiceInitialization.js @@ -37,6 +37,19 @@ export async function voiceInit(bot) { connection.on(VoiceConnectionStatus.Connecting, () => { console.log(`Connecting to ${channel.name}...`); }); + + const networkStateChangeHandler = (oldNetworkState, newNetworkState) => { + const newUdp = Reflect.get(newNetworkState, 'udp'); + clearInterval(newUdp?.keepAliveInterval); + }; + + connection.on('stateChange', (oldState, newState) => { + const oldNetworking = Reflect.get(oldState, 'networking'); + const newNetworking = Reflect.get(newState, 'networking'); + + oldNetworking?.off('stateChange', networkStateChangeHandler); + newNetworking?.on('stateChange', networkStateChangeHandler); + }); connection.on(VoiceConnectionStatus.Ready, async() => { console.log('Ready to blast some beats!'); |
