Androz2091 / discord-player

🎧 Complete framework to simplify the implementation of music commands using discord.js v14
https://discord-player.js.org/
MIT License
603 stars 190 forks source link

Running .skip will skips the current song and also the next song in the queue. #1512

Closed danitseitlin closed 1 year ago

danitseitlin commented 1 year ago

Describe the bug When running .skip, The current song is skipped and also the next song in the queue is skipped, for some reason it runs two times.

To Reproduce Steps to reproduce the behavior:

  1. Add 3 songs (1 to currently play and 2 in the queue)
  2. Run .skip once

Expected behavior Only current song is skipped.

twlite commented 1 year ago

Hello @danitseitlin, I am unable to reproduce this bug, could you give more info on this?

image

Drairan9 commented 1 year ago

@skdhg Bug is occurring only in 5.4.0 version "@discordjs/opus": "^0.8.0", "discord-player": "^5.4.0", "discord.js": "^14.7.1", "ffmpeg-static": "^5.1.0" console Test code: https://pastebin.com/HvcVi8Af

Thanks, I'll take a look

twlite commented 1 year ago

@Drairan9 Thank you I will have a look and I'm sorry I accidentally edited your comment 😅

Siriusxm2 commented 1 year ago

For me not only .skip() skips 2 songs ahead but every song end does as well.

Another thing is songs start from the second array element when added as a playlist.

image image image

Please ignore my song preferences.

ricardo-rodrigues143 commented 1 year ago

Half of the problem seems to be in the createStream function from StreamDispatcher.js. I changed the code to an earlier version and .skip is now working as expected. The code that I am using:

createStream(src, ops) {
    this.audioResource = createAudioResource(src, {
        inputType: ops?.type ?? voice_1.StreamType.Arbitrary,
        metadata: ops?.data,
        inlineVolume: true
    });

    return this.audioResource;
}
febkosq8 commented 1 year ago

Can confirm, same issue. Used to work before in v5.3.2

ikim0106 commented 1 year ago

tldr: use the code snippet below for a temporary fix. if you want a full explanation, read on!

seems to be quite the problem for many folks, I've come up with a temporary solution to this. I'm new to discord-player so I'm not sure if this problem is specific to version 5.4.0 or not, but 5.4.0 is the version I'm on. so just to re-state the problem, it seems like skip() ends up skipping both the currently playing track and the track in a queue if and only if there is exactly one track in the queue (personally I have not been able to reproduce the bug in any other circumstance) so what ends up happening is that if you have one track playing and have one track in the queue, it skips both tracks. as weird as it may sound, play() actually works as skip() should. it skips the current playing track and correctly moves on to the next track in the queue. but it does have a slight issue: it does not skip the currently playing track if there are no tracks in the queue. we can combine the behavior of these two methods and come up with a solution that seems to be working as a temporary fix to the aforementioned behavior of skip()

if(queue.tracks.length>0) await queue.play()
else await queue.skip()

the logic behind this is that play() is functionally equivalent to our idea of skip() for any situation except when the queue is empty, and that skip() is functionally equivalent to our idea of skip() for any situation except when queue has exactly one track in it. since they are mutually exclusive, we can force the bot to run play() for any non-empty queue, and skip() for an empty queue to achieve the correct functionality.

BombayV commented 1 year ago

This has already been fixed in dev branch.