evobot
evobot copied to clipboard
Bug: Disconnecting a bot through Discord's menu bugs out the music
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:
- Play something in the bot.
- Disconnect it by right-clicking on the bot in the voice channel.
- Try to play another video/song.
- 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.
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);
.
Same, and solution works like a charm.
Same issue. Adding a feature like !join or !disconnect might be cool for the future too.
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.
Not sure how stale this issue is when the issue still persists.
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.
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.
Closing this since it has been fixed.
in which file did u do it ?
This issue still persists, can you please reopen?
FYI I was able to fix this issue by removing this line: https://github.com/eritislami/evobot/blob/22d353fe497b366134344e00fd58a80b6d31220c/structs/MusicQueue.ts#L58