Skip to content

Commit

Permalink
Added replace keyword to player.play.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
EvieePy committed Oct 22, 2019
1 parent fbe902e commit 8560b9b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions wavelink/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,26 @@ async def disconnect(self):
self.channel_id = None
await self._get_shard_socket(guild.shard_id).voice_state(self.guild_id, None)

async def play(self, track):
async def play(self, track: Track, *, replace: bool=True):
"""|coro|
Play a WaveLink Track.
Parameters
------------
track: :class:`Track`
The :class:`Track` to initiate playing. If a song is already playing it will be stopped,
and the new track will begin.
The :class:`Track` to initiate playing.
replace: bool
Whether or not the current track, if there is one, should be replaced or not. Defaults to True.
"""
self.last_update = 0
self.last_position = 0
self.position_timestamp = 0
self.paused = False

await self.node._send(op='play', guildId=str(self.guild_id), track=track.id)
no_replace = not replace

await self.node._send(op='play', guildId=str(self.guild_id), track=track.id, noReplace=no_replace)
__log__.debug(f'PLAYER | Started playing track:: {str(track)} ({self.channel_id})')
self.current = track

Expand Down

0 comments on commit 8560b9b

Please sign in to comment.