Androz2091 / discord-music-bot

The perfect music bot for your Discord server! 🤘
238 stars 128 forks source link

"botDisconnect" doesn't emit #78

Closed TheJerryFox closed 2 years ago

TheJerryFox commented 2 years ago

Every other event like the "trackStart" or "trackEnd" event work perfectly fine. But as soon as I disconnect my bot, the "botDisconnect" even just doesn't emit. I still have my old queue and it doesn't send my message either.

EDIT: It also restarts the track every time I move it to another channel EDIT2: So I checked again and it does actually emit, but the problem seems to be in the source code

image It just logs 1 for when it connects and 1 when it disconnects even though it should log 1 and 2 The problem is that newState.channelId is null whenever the bot disconnects, so I dont see how thats even possible

TheJerryFox commented 2 years ago

I changed it to the following code and it works perfectly for me now: image

_handleVoiceState(oldState, newState) {
        const queue = this.getQueue(oldState.guild.id);
        if (!queue)
            return;
        if (oldState.channelId && oldState.channelId !== newState.channelId) {
            if ((queue === null || queue === void 0 ? void 0 : queue.connection) && newState.member.id === newState.guild.me.id)
                queue.connection.channel = newState.channel;
            if (newState.channelId && newState.member.id === newState.guild.me.id || (newState.member.id !== newState.guild.me.id && oldState.channelId === queue.connection.channel.id)) {
                if (!Util_1.Util.isVoiceEmpty(queue.connection.channel))
                    return;
                    // ...

Maybe they should change that in the original package, I really dont know how that was supposed to work. I was working with version 5.2.0 btw.

TheJerryFox commented 2 years ago

Just noticed that this should've been posted under the discord-player package obviously, sorry about that @Androz2091