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

Commit 8560b9b

Browse files
committed
Added replace keyword to player.play.
This allows the user to specify whether or not the current track, if there is one, should be replaced by the new track or not. Defaults to True
1 parent fbe902e commit 8560b9b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

wavelink/player.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,26 @@ async def disconnect(self):
204204
self.channel_id = None
205205
await self._get_shard_socket(guild.shard_id).voice_state(self.guild_id, None)
206206

207-
async def play(self, track):
207+
async def play(self, track: Track, *, replace: bool=True):
208208
"""|coro|
209209
210210
Play a WaveLink Track.
211211
212212
Parameters
213213
------------
214214
track: :class:`Track`
215-
The :class:`Track` to initiate playing. If a song is already playing it will be stopped,
216-
and the new track will begin.
215+
The :class:`Track` to initiate playing.
216+
replace: bool
217+
Whether or not the current track, if there is one, should be replaced or not. Defaults to True.
217218
"""
218219
self.last_update = 0
219220
self.last_position = 0
220221
self.position_timestamp = 0
221222
self.paused = False
222223

223-
await self.node._send(op='play', guildId=str(self.guild_id), track=track.id)
224+
no_replace = not replace
225+
226+
await self.node._send(op='play', guildId=str(self.guild_id), track=track.id, noReplace=no_replace)
224227
__log__.debug(f'PLAYER | Started playing track:: {str(track)} ({self.channel_id})')
225228
self.current = track
226229

0 commit comments

Comments
 (0)