evobot icon indicating copy to clipboard operation
evobot copied to clipboard

Bug: Disconnecting a bot through Discord's menu bugs out the music

Open nikosszzz opened this issue 2 years ago • 3 comments

Describe the bug If you go to your bot that is playing music, and disconnect it using the discord method and then try to play Music again, the queue becomes bugged.

How To Reproduce Steps to reproduce the behavior:

  1. Play something in the bot.
  2. Disconnect it by right-clicking on the bot in the voice channel.
  3. Try to play another video/song.
  4. Bot adds song/video to queue, but does not rejoin voice channel.

Expected behavior On disconnect it should destroy the connection and/or queue.

Environment (add if possible)

  • Node.js version: 16.14.0

Additional information & screenshots Add any other context or screenshots about the problem here.

nikosszzz avatar Jun 14 '22 12:06 nikosszzz

I have fixed this by doing the following:

this.connection.on("stateChange" as any, async (oldState: VoiceConnectionState, newState: VoiceConnectionState) => {
      if (newState.status === VoiceConnectionStatus.Disconnected) {
        if (newState.reason === VoiceConnectionDisconnectReason.WebSocketClose && newState.closeCode === 4014) {
          try {
            this.connection.destroy();
            this.stop();
          } catch (error: any) {
            console.log(error)
            this.connection.destroy();
          }

I have added this.connection.destroy(); and this.stop(); to the part that used to be await entersState(this.connection, VoiceConnectionStatus.Connecting, 5_000);.

nikosszzz avatar Jun 14 '22 16:06 nikosszzz

Same, and solution works like a charm.

xainsworth avatar Jun 17 '22 19:06 xainsworth

Same issue. Adding a feature like !join or !disconnect might be cool for the future too.

wgetgoose avatar Jul 14 '22 21:07 wgetgoose

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 14 '22 00:08 stale[bot]

Not sure how stale this issue is when the issue still persists.

wgetgoose avatar Aug 14 '22 02:08 wgetgoose

Not sure how stale this issue is when the issue still persists.

I’m pretty sure the fix for it is already merged or, if not you can try the fix i posted above.

nikosszzz avatar Aug 14 '22 13:08 nikosszzz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 20 '22 19:09 stale[bot]

Closing this since it has been fixed.

nikosszzz avatar Sep 20 '22 19:09 nikosszzz

in which file did u do it ?

Agentsarkar avatar Feb 12 '23 06:02 Agentsarkar

This issue still persists, can you please reopen?

abarichello avatar Jun 04 '23 03:06 abarichello

FYI I was able to fix this issue by removing this line: https://github.com/eritislami/evobot/blob/22d353fe497b366134344e00fd58a80b6d31220c/structs/MusicQueue.ts#L58

abarichello avatar Jun 04 '23 04:06 abarichello