hmes98318 / Music-Disc

A Discord music bot, supports YouTube, Spotify, SoundCloud, Deezer streams and web dashboard.
https://musicdisc.ggwp.tw
MIT License
107 stars 105 forks source link

Disconnected from voice server after a few seconds of connection #12

Closed hmes98318 closed 1 year ago

hmes98318 commented 1 year ago

Describe the bug Connecting to certain voice servers in specific regions causes the connection to crash every minute.
It seems to be a Discord issue at the moment.

https://github.com/discordjs/discord.js/issues/9185

A workaround is to remove keepAlive timer/interval..
Add the following code to node_modules/discord-player/dist/VoiceInterface/VoiceUtils.js

// line 43
conn.on('stateChange', (old_state, new_state) => {
            const oldNetworking = Reflect.get(old_state, 'networking');
            const newNetworking = Reflect.get(new_state, 'networking');

            const networkStateChangeHandler = (oldNetworkState, newNetworkState) => {
                const newUdp = Reflect.get(newNetworkState, 'udp');
                clearInterval(newUdp?.keepAliveInterval);
            }

            oldNetworking?.off('stateChange', networkStateChangeHandler);
            newNetworking?.on('stateChange', networkStateChangeHandler);
        });

Screenshots image

Version Information:

hmes98318 commented 1 year ago

https://github.com/Androz2091/discord-player/issues/1630

hmes98318 commented 1 year ago

v1.2.7 sloved.