aboutsummaryrefslogtreecommitdiff
path: root/AudioBackend/VoiceInitialization.js
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2023-03-11 18:54:53 -0500
committerGitHub <noreply@github.com>2023-03-11 18:54:53 -0500
commitc520d84a0e3755557f0c8bb47d691fd2beb89c26 (patch)
tree9cd97ae0de078c4f12b9e840cca527eca3cf3d38 /AudioBackend/VoiceInitialization.js
parent4f5a9747dc9b0ce0a9206b311dda3590b179df0b (diff)
downloadDLAP-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.js13
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!');