fix: select the requested track after queue end
This commit is contained in:
2 files changed
+12
-1
No files matched your search
@@ -118,6 +118,17 @@ class MusicPlayerQueueTest(unittest.IsolatedAsyncioTestCase):
|
|||||||
self.assertIsNone(state.current)
|
self.assertIsNone(state.current)
|
||||||
self.assertEqual(state.index, 3)
|
self.assertEqual(state.index, 3)
|
||||||
|
|
||||||
|
async def test_jump_after_queue_end_plays_selected_track(self):
|
||||||
|
player, voice_client, state = await self._queue_abc()
|
||||||
|
state.index = 2
|
||||||
|
await player.play_next(GUILD, advance=True)
|
||||||
|
voice_client.playing = None
|
||||||
|
|
||||||
|
await player.jump(GUILD, 0)
|
||||||
|
|
||||||
|
self.assertEqual(state.index, 0)
|
||||||
|
self.assertEqual(state.current.id, "a")
|
||||||
|
|
||||||
async def test_jump_selects_target_without_advancing_past_it(self):
|
async def test_jump_selects_target_without_advancing_past_it(self):
|
||||||
player, _, state = await self._queue_abc()
|
player, _, state = await self._queue_abc()
|
||||||
await player.jump(GUILD, 2)
|
await player.jump(GUILD, 2)
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ class MusicPlayer:
|
|||||||
index = state.index if state.index != -1 else 0
|
index = state.index if state.index != -1 else 0
|
||||||
|
|
||||||
if not advance:
|
if not advance:
|
||||||
if 0 <= index < len(state.queue) and state.current is not None:
|
if 0 <= index < len(state.queue):
|
||||||
return index
|
return index
|
||||||
return len(state.queue) - 1
|
return len(state.queue) - 1
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user