Player API Reference

class lavaplay.player.Player(node: Node, guild_id: int)[source]

Bases: object

add_to_queue(tracks: List[Track], requester: Optional[int] = None) None[source]

Add tracks to queue. use to load a playlist result.

>>> playlist = lavaplay.search_youtube("playlist url")
>>> lavaplay.add_to_queue(playlist.tracks)

Parameters

tracks: list

tracks to add to queue

async play(track: Track, requester: Optional[int] = None, start: bool = False) None[source]

Play track or add to the queue list.

Parameters

requester: int

user id for requester the play track

start: bool

force play queue is ignored

async play_playlist(playlist: PlayList, requester: Optional[int] = None) None[source]

Play track or add to the queue list.

Parameters

playlist: PlayList

playlist to play

requester: int | None

user id for requester the play track

repeat(stats: bool) None[source]

Repeat the track for every.

Parameters

stats: bool

the stats for repeat track

queue_repeat(stats: bool) None[source]

Repeat the queue for every.

Parameters

stats: bool

the stats for repeat queue

async filters(filters: Optional[Filters]) None[source]

Repeat the track for every.

Parameters

filters: Filters

add filters to the track

async stop() None[source]

Stop the track.

async skip() None[source]

Skip the track

async pause(stats: bool) None[source]

Pause the track.

Parameters

stats: bool

the stats for repeat track

async seek(position: int) None[source]

seek to custom position for the track, the position is in milliseconds.

Parameters

position: int

the position is in milliseconds

async volume(volume: int) None[source]

Set volume for a player track.

Parameters

volume: int

Volume may range from 0 to 1000. 100 is default

Raises

VolumeError

if volume is not in range from 0 to 1000.

async destroy() None[source]

Tell the server to potentially disconnect from the voice server and potentially remove the player with all its data. This is useful if you want to move to a new node for a voice connection. Calling this function does not affect voice state, and you can send the same VOICE_SERVER_UPDATE to a new node.

Parameters

Raises

NodeError

If guild not found in nodes cache.

shuffle(state: bool = True) List[Track][source]

Add shuffle to the track.

Parameters

state: bool

the stats for shuffle track (unused)

remove(position: int) None[source]

Remove a track from the queue.

Parameters

position: int

the position of the track in the queue

index(position: int) Optional[Track][source]

Get the track at a specific position in the queue.

Parameters

position: int

the position of the track in the queue

async voice_update(session_id: str, token: str, endpoint: str, channel_id: Optional[int]) None[source]

Update the voice connection for a guild.

Parameters

session_id: str

session id for connection

token: str

token for connection

endpoint: str

endpoint for connection

channel_id: int

channel id for connection, if not give channel_id the connection will be closed

async raw_voice_state_update(user_id: int, session_id: str, channel_id: Optional[int]) None[source]

A voice state update has been received from Discord.

Parameters

user_id: int

user id

session_id: str

session id

channel_id: int | None

the channel id, if not give the channel id will automatically destroy node.

async raw_voice_server_update(endpoint: str, token: str) None[source]

A voice server update has been received from Discord.

Parameters

endpoint: str

the endpoint for the voice server

token: str

the token for the voice server

property is_connected: bool

Return if the player is connected to voice channel.

property ping: int

Return the ping of the player.

property is_playing: bool

Return if the player is playing.

property is_repeat: bool

Return if the player is repeating the current track.

property is_queue_repeat: bool

Return if the player is repeating the queue.