Hotfix discord breaking changes

This commit is contained in:
2023-03-05 14:48:50 +07:00
parent b44e583834
commit 845b4ed3b1
+18
View File
@@ -282,6 +282,24 @@ export class DiscordMusicPlayerInstance {
}, 2000);
}
);
// Hotfix for VoiceConnection stuck in signalling state around a minute
// https://github.com/discordjs/discord.js/issues/9185
this.voiceConnection.on('stateChange', (oldState: VoiceConnectionState, newState: VoiceConnectionState) => {
const oldNetworking = Reflect.get(oldState, 'networking');
const newNetworking = Reflect.get(newState, 'networking');
const networkStateChangeHandler = (
oldNetworkState: VoiceConnectionState,
newNetworkState: VoiceConnectionState
) => {
const newUdp = Reflect.get(newNetworkState, 'udp');
clearInterval(newUdp?.keepAliveInterval);
};
oldNetworking?.off('stateChange', networkStateChangeHandler);
newNetworking?.on('stateChange', networkStateChangeHandler);
});
}
public async leaveVoiceChannel() {