larsrickert / discord-player-plus

🤖 Library for creating discord music bots using discord.js v14 written in TypeScript.
https://discordplayerplus.lars-rickert.de
MIT License
7 stars 2 forks source link

Bot always stops playing after approximately 50-60 seconds #9

Closed arpitflex closed 1 year ago

arpitflex commented 1 year ago

Describe the bug

After 50-60 seconds of a voice connection, the bot stops playing. This applies to any song or for any server.

When researching this issue, the issue seems to stem from a bug in @discordjs/voice. There are many users with this issue right now https://github.com/discordjs/discord.js/issues/9185, with analysis into the bug can be found here: https://github.com/discordjs/discord.js/issues/9185#issuecomment-1452510633.

However, the quick fix recommended by the other users in the thread, specifically https://github.com/discordjs/discord.js/issues/9185#issuecomment-1452514375, does not seem to work with discord-player-plus.

The fix was attempted by changing player.js to include the networkStateChangeHandler function and the additional stateChange listener to the audio connection. image

This fix seems to work for many of the other users with the same issue, but it doesn't seem to work with discord-player-plus (or at least the way I have incorporated it).

Reproduction

Step 1: Have bot running Step 2: Queue up a song (optimally longer than 60 seconds) Step 3: Let bot play the song Step 4: Bot will abruptly stop at around 50-60 seconds.

System Info

Binaries:
    Node: 18.15.0 - ~\scoop\shims\node.EXE
    npm: 9.5.0 - ~\scoop\shims\npm.CMD

Validations

vittee commented 1 year ago

Because you're applying that to the audioPlayer.

This fix should be applied on the VoiceConnection object.

This line returns a VoiceConnection object, you can apply it there https://github.com/larsrickert/discord-player-plus/blob/e54f74ab5b8bd74a34ee9e1d8ef551ed08614fad/src/player.ts#L268

larsrickert commented 1 year ago

Hey, thanks for reporting the issue! I will investigate this and will look at it ASAP!

arpitflex commented 1 year ago

Because you're applying that to the audioPlayer.

This fix should be applied on the VoiceConnection object.

This line returns a VoiceConnection object, you can apply it there

https://github.com/larsrickert/discord-player-plus/blob/e54f74ab5b8bd74a34ee9e1d8ef551ed08614fad/src/player.ts#L268

This fixes it! I didn't notice the issue as I was quick testing the fix through the player.js in the node_modules. Thanks for the help @vittee.

I have made a PR #10, maybe this helps with your investigation @larsrickert. Not exactly sure how to go about temporary fixes/what should be done when the bug in @discordjs/voice is fixed.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.4.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: