Skip to content

Commit

Permalink
Update index.js (#213)
Browse files Browse the repository at this point in the history
Fix for player autopausing after quitting after 30-60s.

Androz2091/discord-player#1630 (comment)
  • Loading branch information
smclean117 authored Mar 3, 2023
1 parent c04dca3 commit ac4461c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ console.log(client.commands);

const player = new Player(client);

player.on('connectionCreate', (queue) => {
queue.connection.voiceConnection.on('stateChange', (oldState, newState) => {
const oldNetworking = Reflect.get(oldState, 'networking');
const newNetworking = Reflect.get(newState, 'networking');

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

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

player.on('error', (queue, error) => {
console.log(`[${queue.guild.name}] Error emitted from the queue: ${error.message}`);
});
Expand Down

0 comments on commit ac4461c

Please sign in to comment.