API Reference#

NodePool#

class lavapy.NodePool#

Lavapy NodePool class. This holds all the Node objects created with createNode().

classmethod balanced() lavapy.pool.Node#

An algorithm which selects the best Lavapy Node based on each node’s penalty.

Raises
Returns

A Lavapy node object.

Return type

Node

classmethod closestNode(region: VoiceRegion)#

An algorithm which selects the best Lavapy Node based on how close it is to the desired target.

Raises
async classmethod createNode(*, client: Union[discord.Client, discord.AutoShardedClient, discord.ext.commands.Bot, discord.ext.commands.AutoShardedBot], host: str, port: int, password: str, region: Optional[VoiceRegion] = None, secure: bool = False, heartbeat: int = 60, resumeKey: Optional[str] = None, spotifyClient: Optional[SpotifyClient] = None, identifier: Optional[str] = None) Node#

This function is a coroutine.

Creates a Lavapy Node object and stores it for later use.

Parameters
  • client (Union[discord.Client, discord.AutoShardedClient, discord.ext.commands.Bot, discord.ext.commands.AutoShardedBot]) – The client or bot object to assign to this node.

  • host (str) – The IP address of the Lavalink server.

  • port (int) – The port of the Lavalink server.

  • password (str) – The password to the Lavalink server.

  • region (Optional[discord.VoiceRegion]) – The voice region to assign to this node.

  • secure (bool) – Whether to connect securely to the Lavalink server or not.

  • heartbeat (int) – How many seconds to wait before sending a ping message and waiting for a response from the Lavalink server.

  • resumeKey (Optional[str]) – The resume key assigned to this node which allows a player to resume playing if it gets disconnected.

  • spotifyClient (Optional[SpotifyClient]) – A Lavapy Spotify client for interacting with Spotify.

  • identifier (Optional[str]) – The unique identifier for this node. If not supplied, it will be generated for you.

Raises

NodeOccupied – A node with the given identifier already exists.

Returns

A Lavapy node object.

Return type

Node

classmethod extension(extension: Type[Playable])#

An algorithm which selects the best Lavapy Node based on the amount of players.

Raises
classmethod identifier(identifier: str)#

An algorithm which selects the best Lavapy Node based on its identifier.

Raises
classmethod minPlayers() lavapy.pool.Node#

An algorithm which selects the best Lavapy Node based on the amount of players.

Raises
Returns

A Lavapy node object.

Return type

Node

classmethod nodes() Dict[str, lavapy.pool.Node]#

Returns a mapping of identifier to node objects.

classmethod players() List[Player]#

Returns a list of currently connected players.

Node#

Node#

class lavapy.Node(client: Union[discord.Client, discord.AutoShardedClient, discord.ext.commands.Bot, discord.ext.commands.AutoShardedBot], host: str, port: int, password: str, region: Optional[discord.VoiceRegion], secure: bool, heartbeat: int, resumeKey: str, spotifyClient: Optional[SpotifyClient], identifier: str)#

Lavapy Node object.

Warning

This class should not be created manually. Please use NodePool.createNode() instead.

async buildTrack(cls: Type[Track], id: str) Track#

This function is a coroutine.

Builds a Track from a base64 track ID.

Parameters
  • cls (Type[Track]) – The Lavapy resource to return an instance of

  • id (str) – The base64 track ID.

Raises

BuildTrackError – An error occurred while building the track.

Returns

A Lavapy track object.

Return type

Track

async connect() None#

This function is a coroutine.

Initialises the websocket connection to the Lavalink server.

Raises

WebsocketAlreadyExists – The websocket for this node already exists.

async disconnect(*, force: bool = False) None#

This function is a coroutine.

Disconnects this Node and removes it from the NodePool.

Parameters

force (bool) – Whether to force the disconnection. This is currently not used.

async getTracks(cls: Type[Playable], query: str) Optional[Union[Track, List[Track], MultiTrack]]#

This function is a coroutine.

Gets data about a Track or MultiTrack from Lavalink.

Parameters
  • cls (Type[Playable]) – The Lavapy resource to create an instance of.

  • query (str) – The query to search for via Lavalink.

Returns

A Lavapy resource which can be used to play music.

Return type

Optional[Union[Track, List[Track], MultiTrack]]

property client: Union[discord.Client, discord.AutoShardedClient, discord.ext.commands.Bot, discord.ext.commands.AutoShardedBot]#

Returns the client or bot object assigned to this node.

property heartbeat: int#

Returns the amount of seconds between ping requests.

property host: str#

Returns the IP address of the Lavalink server.

property identifier: str#

Returns the unique identifier for this node.

property password: str#

Returns the password to the Lavalink server.

property penalty: float#

Returns the load balancing penalty for this node.

property players: List[Player]#

Returns a list of all Lavapy player objects which are connected to this node.

property port: int#

Returns the port of the Lavalink server.

property region: Optional[discord.VoiceRegion]#

Returns the voice region assigned to this node.

property restUri: str#

Returns the URI used for communicating with the Lavalink server.

property resumeKey: str#

Returns the resume key assigned to this node.

property secure: bool#

Returns whether the connection to the Lavalink server is secure or not.

property session: aiohttp.client.ClientSession#

Returns the session used for sending and getting data.

property spotifyClient: Optional[SpotifyClient]#

Returns the Spotify client associated with this node if there is one.

property stats: Optional[lavapy.stats.Stats]#

Returns useful information sent by Lavalink about this node.

property websocketUri: str#

Returns the URI used for initialising the websocket.

Stats#

class lavapy.Stats(node: Node, data: Dict[str, Any])#

Stores useful information sent by Lavalink about this Node.

node#

The Lavapy node these stats are about.

Type

Node

uptime#

How long this node has been up for.

Type

int

players#

How many players are connected to this node.

Type

int

playingPlayers#

How many players that are connected to this node are playing tracks.

Type

int

memoryReservable#

How much memory is reserved by the system.

Type

int

memoryUsed#

How much memory is used by the system.

Type

int

memoryFree#

How much memory is free in the system.

Type

int

memoryAllocated#

How much memory is allocated to Lavalink.

Type

int

cpuCores#

How many cpu cores the system has.

Type

int

systemLoad#

The load on the system as a percentage.

Type

float

lavalinkLoad#

The load on the Lavalink server as a percentage.

Type

float

framesSent#

How many frames have been sent to Lavalink by this node.

Type

int

framesDeficit#

How many frames have been lost that were sent by this node.

Type

int

framesNulled#

How many frames have errored that were sent by this node.

Type

int

Player#

Player#

class lavapy.Player(client: Union[discord.Client, discord.AutoShardedClient, discord.ext.commands.Bot, discord.ext.commands.AutoShardedBot], channel: discord.VoiceChannel)#

Lavapy Player object. This subclasses discord.VoiceProtocol and such should be treated as one with additions.

Examples

@commands.command()
async def connect(self, channel: discord.VoiceChannel):
    voice_client = await channel.connect(cls=lavapy.Player)

Warning

This class should not be created manually but can be subclassed to add additional functionality. You should instead use discord.VoiceChannel.connect() and pass the player object to the cls kwarg.

Parameters
async addFilter(filter: LavapyFilter) None#

This function is a coroutine.

Adds a LavapyFilter to the player.

Warning

This requires Lavalink 3.4 or greater..

Parameters

filter (LavapyFilter) – The filter to apply to the player.

Raises

FilterAlreadyExists – The specific filter is already applied.

async connect(*, timeout: float, reconnect: bool, selfDeaf: bool = False, selfMute: bool = False) None#

This function is a coroutine.

Connects the player to a discord.VoiceChannel.

Parameters
  • timeout (float) – The timeout for the connection.

  • reconnect (bool) – A bool stating if reconnection is expected.

  • selfDeaf (bool) – Whether the player should connect deafened or not.

  • selfMute (bool) – Whether the player should connect muted or not.

async destroy() None#

This function is a coroutine.

Disconnects and destroys the player.

async disconnect(*, force: bool = False) None#

This function is a coroutine.

Disconnects the player from a discord.VoiceChannel.

Parameters

force (bool) – Whether to force the disconnection. This is currently not used.

async moveTo(channel: discord.channel.VoiceChannel) None#

This function is a coroutine.

Moves the player to another discord.VoiceChannel. If this is None, then the player will disconnect.

Parameters

channel (discord.VoiceChannel) – The voice channel to move to.

async on_voice_server_update(data: Dict[str, str]) None#

This function is a coroutine.

Called when the client connects to a voice channel.

Parameters

data (Dict[str, str]) – The raw info sent by Discord about the voice channel.

async on_voice_state_update(data: Dict[str, Any]) None#

This function is a coroutine.

Called when the client’s voice state changes.

Parameters

data (Dict[str, Any]) – The raw info sent by Discord about the client’s voice state.

async pause() None#

This function is a coroutine.

Pauses the Player if it was playing.

async play(track: Union[Track, PartialResource, MultiTrack], startTime: int = 0, endTime: int = 0, volume: float = 1, replace: bool = True, pause: bool = False) Optional[Track]#

This function is a coroutine.

Plays a given resource. If this resource is a Track, it is played normally. However, if it is a PartialResource, then it is searched for and played (if the result of the search is a list of tracks, then the first is played). If the resource is a MultiTrack then the first track is played and the rest and sent to the Queue.

Parameters
  • track (Union[Track, PartialResource, MultiTrack]) – The Lavapy resource to play.

  • startTime (int) – The position in milliseconds to start at. By default, this is the beginning.

  • endTime (int) – The position in milliseconds to end at. By default, this is the end.

  • volume (int) – The volume at which the player should play the track at. This should be a value between 0 and 5 where 1 is 100%.

  • replace (bool) – A bool stating if the current track should be replaced or not.

  • pause (bool) – A bool stating if the track should start paused.

Returns

The currently playing Lavapy track.

Return type

Optional[Track]

async removeFilter(filter: Union[LavapyFilter, Type[LavapyFilter]]) None#

This function is a coroutine.

Removes a LavapyFilter based on its name.

Warning

This requires Lavalink 3.4 or greater.

Parameters

filter (Union[LavapyFilter, Type[LavapyFilter]]) – The filter to remove. This can either be a non-initialised class like lavapy.Equalizer or an initialised one like lavapy.Equalizer.flat().

Raises

FilterNotApplied – The specific filter is not applied.

async resetFilter(filter: Type[LavapyFilter]) None#

This function is a coroutine.

Resets a LavapyFilter.

Warning

This requires Lavalink 3.4 or greater.

Parameters

filter (Type[LavapyFilter]) – The filter to reset. This should be a non-initialised class like lavapy.Equalizer or lavapy.Karaoke.

Raises

FilterNotApplied – The specific filter is not applied.

async resume() None#

This function is a coroutine.

Resumes the Player if it was paused.

async seek(position: int) None#

This function is a coroutine.

Seek to a given position.

Parameters

position (int) – The position to seek to.

Raises

InvalidIdentifier – Seek position is bigger than the track length.

async setVolume(volume: float) None#

This function is a coroutine.

Changes the Player’s volume.

Parameters

volume (float) – The new volume. This should be a value between 0 and 5 where 1 is 100%.

startRepeat() None#

Repeats the currently playing track.

Raises

RepeatException – The player is already repeating.

async stop() None#

This function is a coroutine.

Stops the currently playing Track.

stopRepeat() None#

Stops repeating the currently playing track.

Raises

RepeatException – The player is not repeating.

property filters: Dict[str, LavapyFilter]#

Returns all the currently applied filters if there are any.

property guild: discord.guild.Guild#

Returns the guild this player is in.

property isConnected: bool#

Returns whether the player is connected to a channel or not.

property isDead: bool#

Returns whether the player is dead or not. A player is considered dead if it has been destroyed and removed from stored players.

property isPaused: bool#

Returns whether the player is currently paused or not.

property isPlaying: bool#

Returns whether the player is currently playing a track or not.

property isRepeating: bool#

Returns whether the player is repeating the current track or not.

property node: Optional[Node]#

Returns the Lavapy node this player is connected to.

property position: float#

Returns the current position of the track in seconds. If nothing is playing, this returns 0.

property queue: lavapy.queue.Queue#

Returns a queue object which can be used to line up and retrieve tracks.

property track: Optional[Track]#

Returns the currently playing track if there is one.

property volume: float#

Returns the current volume.

Queue#

class lavapy.Queue(player: Player)#

A class representing a usable Queue.

add(track: Track) None#

Adds a Track to the queue.

Parameters

track (Track) – The track to add to the queue.

addIterable(iterable: Union[MultiTrack, Iterable[Track]]) None#

Adds an iterable to the Queue.

Parameters

iterable (Union[MultiTrack, Iterable[Track]]) – The iterable to add to the queue.

next() Track#

Gets the next Track in the queue.

Raises
Returns

The next track in the queue.

Return type

Track

previous() Track#

Gets the previous Track in the queue.

Raises
Returns

The previous track in the queue.

Return type

Track

reset() None#

Resets the queue.

shuffle() None#

Shuffles the queue but keeps the currently playing track in the same place.

property count: int#

Returns the size of the queue.

property currentTrack: int#

Returns the current position in the queue.

property isEmpty: bool#

Returns whether the queue is empty or not.

property tracks: List[Track]#

Returns a list of track objects.

Playables#

Note

Remember to check if the specific source is enabled in your Lavalink application.yml.

DecodeQuery#

lavapy.decodeQuery(query: str) Type[lavapy.tracks.Playable]#

Decodes a query into a Playable type which can be searched.

Parameters

query (str) – The query to decode.

Returns

The playable type which can be searched.

Return type

Type[Playable]

Playable#

class lavapy.Playable(*data: Any)#

The base class for all Lavapy resources. This supports both query searches and identifier searches.

Warning

This class should not be created manually. Instead use a subclass of Track or MultiTrack.

async classmethod search(query: str, node: Node = None, returnFirst: bool = True, partial: bool = False) Optional[Union[Playable, Track, List[Track], PartialResource, List[PartialResource], MultiTrack]]#

This function is a coroutine.

Performs a search to Lavalink for a specific resource.

Parameters
  • query (str) – The query to search for.

  • node (Node) – The Lavapy Node to use for searching. If this is not supplied, a random one from the node pool will be retrieved.

  • returnFirst (bool) – Whether to return only the first result or not.

  • partial (bool) – Whether to return a Lavapy partial resource or not.

Returns

A Lavapy resource or a list of resources which can be used to play music.

Return type

Optional[Union[Playable, Track, List[Track], PartialResource, List[PartialResource], MultiTrack]]

PartialResource#

class lavapy.PartialResource(cls: Type[lavapy.tracks.Playable], query: str)#

A class which searches for the given query at playtime.

Warning

It is advised not to create this manually, however, it is possible to do so.

Parameters
  • cls (Type[Playable]) – The resource to create a instance of at playtime.

  • query (str) – The query to search for at playtime.

  • warning:: (..) – This object will only search for the given query at playtime. Full resource information will be missing until it has been searched. It is advised not to create this manually, however, it is possible to do so.

property cls: Type[lavapy.tracks.Playable]#

Returns the resource which will be created at playtime.

property query: str#

Returns the query which will be searched for at playtime.

Track#

class lavapy.Track(id: str, info: Dict[str, Any])#

The base class for all Lavapy Track objects.

Warning

It is advised not to create this manually, however, it is possible to do so.

Parameters
  • id (str) – The unique base64 track ID which can be used to rebuild a track.

  • info (Dict[str, Any]) – The raw track info.

property author: str#

Returns the author of the track.

property id: str#

Returns the base64 track ID.

property identifier: str#

Returns the track’s unique identifier.

property isSeekable: bool#

Returns whether a track is seekable or not.

property isStream: bool#

Returns whether the track is a stream or not.

property length: int#

Returns the duration of the track in seconds.

property title: str#

Returns the title of the track.

property type: str#

Returns the source site of the track.

property uri: str#

Returns the URI of the track.

MultiTrack#

class lavapy.MultiTrack(name: str, tracks: List[lavapy.tracks.Track])#

The base class for all Lavapy MultiTrack resources. These could be playlists or albums.

Warning

It is advised not to create this manually, however, it is possible to do so.

Parameters
  • name (str) – The name of the playlist.

  • tracks (List[Track]) – The playlist’s tracks as a list of Lavapy Track objects.

property name: str#

Returns the name of the playlist.

property tracks: List[lavapy.tracks.Track]#

Returns the playlist’s tracks.

YoutubeTrack#

class lavapy.YoutubeTrack(id: str, info: Dict[str, Any])#

Bases: lavapy.tracks.Track, lavapy.tracks.Playable

A track created using a search to Youtube.

property thumbnail: str#

Returns the URI to the thumbnail of this track.

YoutubeMusicTrack#

class lavapy.YoutubeMusicTrack(id: str, info: Dict[str, Any])#

Bases: lavapy.tracks.Track, lavapy.tracks.Playable

A track created using a search to Youtube Music.

SoundcloudTrack#

class lavapy.SoundcloudTrack(id: str, info: Dict[str, Any])#

Bases: lavapy.tracks.Track, lavapy.tracks.Playable

A track created using a search to Soundcloud.

LocalTrack#

class lavapy.LocalTrack(id: str, info: Dict[str, Any])#

Bases: lavapy.tracks.Track, lavapy.tracks.Playable

A track created using a search to a Discord mp3 file.

YoutubePlaylist#

class lavapy.YoutubePlaylist(name: str, tracks: List[lavapy.tracks.Track])#

Bases: lavapy.tracks.MultiTrack, lavapy.tracks.Playable

A playlist created using a search to Youtube.

Filters#

LavapyFilter#

class lavapy.LavapyFilter#

Base Lavapy Filter. Every filter inherit from this.

property payload: Any#

Returns the payload to be sent to Lavalink.

Equalizer#

class lavapy.Equalizer(levels: List[Tuple[int, float]], name: str)#

Bases: lavapy.filters.LavapyFilter

A class representing a usable equalizer.

Parameters
  • levels (List[Tuple[int, float]]) – A list of tuple pairs containing a band int and gain float.

  • name (str) – A string to name this equalizer.

classmethod build(levels: List[Tuple[int, float]], name: str = 'CustomEqualizer') lavapy.filters.Equalizer#

Build a custom equalizer with the given levels.

Parameters
  • levels (List[Tuple[int, float]]) – A custom list of tuple pairs containing a band int and gain float. You will have to construct this yourself. There should be between 0 and 14 bands with each gain being between -0.25 and 1

  • name (str) – An optional string to name this equalizer. If this is not supplied, it will be set to ‘CustomEqualizer’.

Returns

A custom equalizer object.

Return type

Equalizer

classmethod flat() lavapy.filters.Equalizer#

A flat equalizer. This will not provide a cut or boost to any frequency.

Returns

A flat equalizer object.

Return type

Equalizer

property equalizerName: str#

Returns the name of this equalizer.

property levels: List[Tuple[int, float]]#

Returns a list of tuple pairs containing a band int and gain float.

Karaoke#

class lavapy.Karaoke(level: float = 1.0, monoLevel: float = 1.0, filterBand: float = 220.0, filterWidth: float = 100.0)#

Bases: lavapy.filters.LavapyFilter

Simulates an Equalizer which specifically targets removing vocals.

level#

The level of the karaoke filter.

Type

float

monoLevel#

The monolevel of the karaoke filter.

Type

float

filterBand#

The filter band of the karaoke filter.

Type

float

filterWidth#

The filter width of the karaoke filter.

Type

float

Timescale#

class lavapy.Timescale(speed: float = 1.0, pitch: float = 1.0, rate: float = 1.0)#

Bases: lavapy.filters.LavapyFilter

Changes the speed, pitch and rate of a track. You can make some very cool sound effects with this such as a vaporwave-esque filter which slows the track down a certain amount to produce said effect.

speed#

The speed of the timescale filter. This should be more than or equal to 0.

Type

float

pitch#

The pitch of the timescale filter. This should be more than or equal to 0.

Type

float

rate#

The rate of the timescale filter. This should be more than or equal to 0.

Type

float

Tremolo#

class lavapy.Tremolo(frequency: float = 2.0, depth: float = 0.5)#

Bases: lavapy.filters.LavapyFilter

Uses amplification to create a shuddering effect, where the volume quickly oscillates.

Here is an Example.

frequency#

The frequency of the tremolo filter. This must be bigger than 0.

Type

float

depth#

The depth of the tremolo filter. This must be between 0 and 1.

Type

float

Raises

InvalidFilterArgument – An invalid filter argument has been passed.

Vibrato#

class lavapy.Vibrato(frequency: float = 2.0, depth: float = 0.5)#

Bases: lavapy.filters.LavapyFilter

Similar to Tremolo but oscillates the pitch instead of the volume.

frequency#

The frequency of the vibrato filter. This must be between 0 and 14.

Type

float

depth#

The depth of the tremolo filter. This must be between 0 and 1.

Type

float

Raises

InvalidFilterArgument – An invalid filter argument has been passed.

Rotation#

class lavapy.Rotation(rotationHz: float = 0.0)#

Bases: lavapy.filters.LavapyFilter

Rotates the sound around the stereo channels/user headphones aka Audio Panning.

Here is an Example ( without the reverb).

Parameters

rotationHz (float) – The frequency of the audio rotating around the listener in hertz (0.2 is similar to the example above).

Distortion#

class lavapy.Distortion(sinOffset: float = 0.0, sinScale: float = 1.0, cosOffset: float = 0.0, cosScale: float = 1.0, tanOffset: float = 0.0, tanScale: float = 1.0, offset: float = 0.0, scale: float = 1.0)#

Bases: lavapy.filters.LavapyFilter

Distorts the sound. This can generate some pretty unique audio effects.

sinOffset#

The sine offset of the distortion filter.

Type

float

sinScale#

The sine scale of the distortion filter.

Type

float

cosOffset#

The cosine offset of the distortion filter.

Type

float

cosScale#

The cosine scale of the distortion filter.

Type

float

tanOffset#

The tangent offset of the distortion filter.

Type

float

tanScale#

The tangent scale of the distortion filter.

Type

float

offset#

The offset of the distortion filter.

Type

float

scale#

The scale of the distortion filter.

Type

float

ChannelMix#

class lavapy.ChannelMix(leftToLeft: float = 1.0, leftToRight: float = 0.0, rightToLeft: float = 0.0, rightToRight: float = 1.0)#

Bases: lavapy.filters.LavapyFilter

Mixes both channels (left and right) with a configurable factor on how much each channel affects the other. By default, both channel are kept separate from each other. Setting all factors to 0.5 means both channels get the same audio.

leftToLeft#

The channel mix of left to left. This must be between 0 and 1.

Type

float

leftToRight#

The channel mix of left to right. This must be between 0 and 1.

Type

float

rightToLeft#

The channel mix of right to left. This must be between 0 and 1.

Type

float

rightToRight#

The channel mix of right to right. This must be between 0 and 1.

Type

float

LowPass#

class lavapy.LowPass(smoothing: float = 20.0)#

Bases: lavapy.filters.LavapyFilter

Suppresses higher frequencies, while allowing lower frequencies to pass through.

smoothing#

The smoothing of the low pass filter.

Type

float

Events#

LavapyEvent#

class lavapy.LavapyEvent(event: str, player: Optional[Player])#

Base Lavapy event. Every event inherits from this.

If you want to listen to these events, use a discord.ext.commands.Bot.listen().

Parameters
  • event (str) – The event name.

  • player (Optional[Player]) – A Lavapy player object.

property event: str#

Returns the event name.

property payload: Dict[str, Any]#

Returns a dict containing the payload sent to discord.py. This must be parsed to **kwargs.

TrackStartEvent#

class lavapy.TrackStartEvent(player: Player, track: Track)#

Bases: lavapy.events.LavapyEvent

Fired when a Track starts playing. This can be listened to with:

@bot.listen()
async def on_lavapy_track_start(player, track):
    ...
Parameters
  • player (Player) – A Lavapy player object.

  • track (Track) – A Lavapy track object.

TrackEndEvent#

class lavapy.TrackEndEvent(player: Player, track: Track, data: Dict[str, Any])#

Bases: lavapy.events.LavapyEvent

Fired when a Track stops playing. This can be listened to with:

@bot.listen()
async def on_lavapy_track_end(player, track, reason):
    ...
Parameters
  • player (Player) – A Lavapy player object.

  • track (Track) – A Lavapy track object.

  • data (Dict[str, Any]) – The raw event data.

TrackExceptionEvent#

class lavapy.TrackExceptionEvent(player: Player, track: Track, data: Dict[str, Any])#

Bases: lavapy.events.LavapyEvent

Fired when a Track error has occurred in Lavalink. This can be listened to with:

@bot.listen()
async def on_lavapy_track_exception(player, track, exception):
    ...
Parameters
  • player (Player) – A Lavapy player object.

  • track (Track) – A Lavapy track object.

  • data (Dict[str, Any]) – The raw event data.

TrackStuckEvent#

class lavapy.TrackStuckEvent(player: Player, track: Track, data: Dict[str, Any])#

Bases: lavapy.events.LavapyEvent

Fired when a Track is stuck and cannot be played. This can be listened to with:

@bot.listen()
async def on_lavapy_track_stuck(player, track, threshold):
    pass
Parameters
  • player (Player) – A Lavapy player object.

  • track (Track) – A Lavapy track object.

  • data (Dict[str, Any]) – The raw event data.

WebsocketOpenEvent#

class lavapy.WebsocketOpenEvent(node: Node)#

Bases: lavapy.events.LavapyEvent

Fired when a websocket connection to a Node is open. This can be listened to with:

@bot.listen()
async def on_lavapy_websocket_open(node):
    pass
Parameters

node (lavapy.pool.Node) – A Lavapy node object.

WebsocketClosedEvent#

class lavapy.WebsocketClosedEvent(node: Node, data: Dict[str, Any])#

Bases: lavapy.events.LavapyEvent

Fired when a websocket connection to a Node is closed. This can be listened to with:

@bot.listen()
async def on_lavapy_websocket_closed(node, reason, code, byRemote):
    pass
Parameters
  • node (lavapy.pool.Node) – A Lavapy node object.

  • data (Dict[str, Any]) – The raw event data.

Exceptions#

exception lavapy.LavapyException#

Base Lavapy exception. Every exception inherits from this.

exception lavapy.NoNodesConnected#

Bases: lavapy.exceptions.LavapyException

Exception raised when an operation is attempted with nodes and there are none connected.

exception lavapy.NodeOccupied#

Bases: lavapy.exceptions.LavapyException

Exception raised when node identifiers conflict.

exception lavapy.InvalidSeekPosition#

Bases: lavapy.exceptions.LavapyException

Exception raised when an invalid seek position is passed.

exception lavapy.QueueEmpty#

Bases: lavapy.exceptions.LavapyException

Exception raised when attempting to get a track from an empty queue.

exception lavapy.InvalidFilterArgument#

Bases: lavapy.exceptions.LavapyException

Exception raised when an invalid argument is passed to a filter.

exception lavapy.FilterAlreadyExists#

Bases: lavapy.exceptions.LavapyException

Exception raised when a new filter is attempted to be applied, but it already exists.

exception lavapy.FilterNotApplied#

Bases: lavapy.exceptions.LavapyException

Exception raised when a filter is attempted to be removed, but it is not applied.

exception lavapy.InvalidNodeSearch#

Bases: lavapy.exceptions.LavapyException

Exception raised when a search for a node is invalid.

exception lavapy.RepeatException#

Bases: lavapy.exceptions.LavapyException

Exception raised when an error occurred when enabling or disabling repeat.

exception lavapy.LavalinkException#

Bases: lavapy.exceptions.LavapyException

Base exception raised when an error occurs communicating with Lavalink.

exception lavapy.LoadTrackError#

Bases: lavapy.exceptions.LavalinkException

Exception raised when an error occurred when loading a track.

exception lavapy.BuildTrackError#

Bases: lavapy.exceptions.LavalinkException

Exception raised when an error occurred when building a track.