Hopefully fixed an issue that causes the audio to stop in a minute?

This commit is contained in:
Andrew Lee 2023-03-11 18:54:53 -05:00 committed by GitHub
parent 4f5a9747dc
commit c520d84a0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,19 @@ export async function voiceInit(bot) {
connection.on(VoiceConnectionStatus.Connecting, () => { connection.on(VoiceConnectionStatus.Connecting, () => {
console.log(`Connecting to ${channel.name}...`); 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() => { connection.on(VoiceConnectionStatus.Ready, async() => {
console.log('Ready to blast some beats!'); console.log('Ready to blast some beats!');