Skip to content
This repository was archived by the owner on Apr 5, 2025. It is now read-only.

Commit 50c0403

Browse files
committed
Fix a bug with player.is_playing returning True when there is no Track.
`player.play(track=..., replace=False)` should no longer effect internals when there is a current track playing.
1 parent 2355a8c commit 50c0403

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

wavelink/player.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from .errors import *
3030
from .eqs import *
31-
from .events import TrackStart
31+
from .events import *
3232

3333

3434
__log__ = logging.getLogger(__name__)
@@ -168,7 +168,8 @@ async def _dispatch_voice_update(self):
168168
await self.node._send(op='voiceUpdate', guildId=str(self.guild_id), **self._voice_state)
169169

170170
async def hook(self, event):
171-
pass
171+
if isinstance(event, (TrackEnd, TrackException, TrackStuck)):
172+
self.current = None
172173

173174
def _get_shard_socket(self, shard_id: int) -> Optional[DiscordWebSocket]:
174175
if isinstance(self.bot, commands.AutoShardedBot):
@@ -225,10 +226,13 @@ async def play(self, track: Track, *, replace: bool = True, start: int = 0, end:
225226
The position to end the track on in milliseconds. By default this always allows the current
226227
song to finish playing.
227228
"""
228-
self.last_update = 0
229-
self.last_position = 0
230-
self.position_timestamp = 0
231-
self.paused = False
229+
if replace or not self.is_playing:
230+
self.last_update = 0
231+
self.last_position = 0
232+
self.position_timestamp = 0
233+
self.paused = False
234+
else:
235+
return
232236

233237
no_replace = not replace
234238

0 commit comments

Comments
 (0)