Connection¶
-
class
pylava.
Connection
(bot: typing.Union[discord.ext.commands.bot.Bot, discord.ext.commands.bot.AutoShardedBot], password: str, ws_url: str, rest_url: str)¶ -
coroutine
connect
()¶ Connects to Lavalink. Gets automatically called once when the Connection object is created.
-
connected
¶ Returns the Lavalink connection state.
-
coroutine
disconnect
()¶ Disconnects from Lavalink.
-
get_player
(guild_id: int) → pylava.player.Player¶ Gets a Player class that abstracts away connection handling, among other things.
You shouldn’t be holding onto these for too long, rather you should be requesting them as necessary using this method.
Parameters: guild_id – The guild ID to get the player for. Returns: A Player instance for that guild.
-
coroutine
query
(query: str, *, retry_count=0, retry_delay=0) → list¶ Queries Lavalink. Returns a list of Track objects (dictionaries).
Parameters: - query – The search query to make.
- retry_count – How often to retry the query should it fail. 0 disables, -1 will try forever (dangerous).
- retry_delay – How long to sleep for between retries.
-
coroutine
wait_until_ready
()¶ Waits indefinitely until the Lavalink connection has been established.
-
coroutine
Player¶
-
class
pylava.
Player
(connection, guild_id: int)¶ -
channel
¶ Returns the channel the player is connected to.
-
coroutine
connect
(channel_id: int)¶ Connects the player to a Discord channel.
-
connected
¶ Returns the player’s connected state.
-
coroutine
disconnect
()¶ Disconnects the player from Discord.
-
guild
¶ Returns the player’s guild.
-
paused
¶ Returns the player’s paused state.
-
coroutine
play
(track: str, start_time: float = 0.0, end_time: float = None)¶ Plays a track. If already playing, replaces the current track.
Parameters: - track – A base64 track ID returned by the
Connection.query()
method. - start_time – (optional) How far into the track to start playing (defaults to 0).
- end_time – (optional) At what point in the track to stop playing (defaults to track length).
- track – A base64 track ID returned by the
-
playing
¶ Returns the player’s playing state.
-
position
¶ Returns the player’s current position in seconds.
-
coroutine
query
(*args, **kwargs)¶ Shortcut method for
Connection.query()
.
-
coroutine
seek
(position: float)¶ Seeks to a specific position in a track.
-
coroutine
set_pause
(paused: bool)¶ Sets the pause state.
-
coroutine
set_volume
(volume: int)¶ Sets the player’s volume.
Parameters: volume – An integer between (and including) 0 and 150.
-
coroutine
stop
()¶ Stops the player.
-
stopped
¶ Returns the player’s stopped (neither playing nor paused) state.
-
track_callback
¶ Accesses the track callback.
This is the callable that will be called with the current player’s instance as its first argument. It may be awaitable. If it is None, it will be ignored.
-
volume
¶ Returns the player’s volume.
-