Events

Track

Track Start

Called when a track starts playing.

Parameters

player: sonolink.Player

The player that is playing the track.

payload: sonolink.gateway.TrackStartEvent

The event payload containing information about the track that started playing.

class sonolink.gateway.TrackStartEvent[source]
Attributes

Represents a track start event.

property node: Node

The node that received the event.

track

The track that started playing.

Track End

Called when a track ends.

Parameters

player: sonolink.Player

The player that was playing the track.

payload: sonolink.gateway.TrackEndEvent

The event payload containing information about the track that finished playing and the reason it ended.

class sonolink.gateway.TrackEndEvent[source]
Attributes

Represents a track end event.

property node: Node

The node that received the event.

reason: TrackEndReason

The reason the track ended.

track

The track that ended playing.

Track Exception

Called when an exception occurs while playing a track.

Parameters

player: sonolink.Player

The player that was playing the track.

payload: sonolink.gateway.TrackExceptionEvent

The event payload containing information about the track that caused the exception and the exception.

class sonolink.gateway.TrackExceptionEvent[source]
Attributes

Represents a track exception event.

exception: events.TrackException

The occurred exception.

property node: Node

The node that received the event.

track

The track that thew the exception.

Track Stuck

Called when a track gets stuck while playing.

Parameters

player: sonolink.Player

The player that was playing the track.

payload: sonolink.gateway.TrackStuckEvent

The event payload containing information about the track that got stuck and the threshold that was exceeded.

class sonolink.gateway.TrackStuckEvent[source]
Attributes

Represents a track stuck event.

property node: Node

The node that received the event.

threshold: int

The threshold in milliseconds that was exceeded.

track

The track that got stuck.

Node

Node Ready

Called when a node is ready.

Parameters

payload: sonolink.gateway.ReadyEvent

The event payload containing information about the node that is ready.

class sonolink.gateway.ReadyEvent[source]
Attributes

Represents a ready event.

property node: Node

The node that received the event.

resumed: bool

Whether the session was resumed, if this is False it implies a new connection was created.

session_id: str

The secret session ID.

Node Close

Called when a node is closed.

Parameters

node: sonolink.Node

The node that was closed.

Node Stats

Called when the node receives stats OP from Lavalink.

Added in version 1.1.0.

Parameters

node: sonolink.Node

The node that sent the statistics.

payload: sonolink.gateway.StatsEvent

The event payload containing information about the node’s resource usage, player counts, and uptime.

class sonolink.gateway.StatsEvent[source]

Represents a stats event.

cpu: receive.CPUStats

The CPU stats of the node.

frame_stats: receive.FrameStats | None

The frame stats of the node.

memory: receive.MemoryStats

The memory stats of the node.

property node: Node

The node that received the event.

players: int

The players count attached to the node.

playing_players: int

The players count attached to the node that are playing a track.

uptime: int

The node uptime in milliseconds.

Player

Player Update

Called when a player is updated.

Parameters

player: sonolink.Player

The player that was updated.

payload: sonolink.gateway.PlayerUpdateEvent

The event payload containing information about the player’s current state.

class sonolink.gateway.PlayerUpdateEvent[source]
Attributes

Represents a player_update event.

guild_id: int

The guild ID of the player.

property node: Node

The node that received the event.

state: receive.PlayerState

The state of the player.

WebSocket Closed

Called when the voice WebSocket connection to Lavalink is closed.

Added in version 1.1.0.

Parameters

player: sonolink.Player

The player whose voice WebSocket was closed.

Warning

This player is not meant to be reused, you should create another Player instance instead.

payload: sonolink.gateway.WebSocketClosedEvent

The event payload containing the close code, reason, and whether the close was initiated by the remote end.

class sonolink.gateway.WebSocketClosedEvent[source]
Attributes

Represents a ws_close event.

by_remote: bool

Whether the closure was made by Discord.

code: int

The Discord close event code.

property node: Node

The node that received the event.

reason: str

The reason why the connection was closed.

Player Disconnect

A custom SonoLink event called whenever a player is disconnected.

Unlike on_sonolink_websocket_closed(), this method is called only when you, or the library, manually disconnects a sonolink.Player.

Added in version 1.1.0.

Parameters

player: sonolink.Player

The player which was disconnected.

Warning

This player is not meant to be reused, you should create another Player instance instead.

payload: sonolink.gateway.PlayerDisconnectEvent

The event payload containing the trigger that caused the disconnect, along with extra data.

class sonolink.gateway.PlayerDisconnectEvent[source]
Attributes

Represents a player disconnected event.

property node: Node

The node that received the event.

trigger: DisconnectTriggerType

The trigger that caused the disconnect.

Miscellaneous

Unknown Event

Called when an unknown event is received. This can be from plugins/extensions on Lavalink.

Parameters

player: sonolink.Player

The player that received the unknown event.

payload: dict

The raw event payload that was received.