Events#

Classes#

class mafic.WebSocketClosedEvent(*, payload, player)#

Bases: Generic[PlayerT]

Represents an event when the connection to Discord is lost.

code#

The close code. Find what this can be in the Discord docs.

Type:

int

reason#

The close reason.

Type:

str

by_discord#

Whether the close was initiated by Discord.

Type:

bool

player#

The player that the event was dispatched from.

Type:

Player

Attributes
class mafic.TrackStartEvent(*, track, player)#

Bases: Generic[PlayerT]

Represents an event when a track starts playing.

track#

The track that started playing.

Type:

Track

player#

The player that the event was dispatched from.

Type:

Player

Attributes
class mafic.TrackEndEvent(*, track, payload, player)#

Bases: Generic[PlayerT]

Represents an event when a track ends.

track#

The track that ended.

Type:

Track

reason#

The reason why the track ended.

Type:

EndReason

player#

The player that the event was dispatched from.

Type:

Player

Attributes
class mafic.TrackExceptionEvent(*, track, payload, player)#

Bases: Generic[PlayerT]

Represents an event when an exception occurs while playing a track.

track#

The track that caused the exception.

Type:

Track

exception#

The exception that was raised.

Type:

Exception

player#

The player that the event was dispatched from.

Type:

Player

class mafic.TrackStuckEvent(*, track, payload, player)#

Bases: Generic[PlayerT]

Represents an event when a track gets stuck.

track#

The track that got stuck.

Type:

Track

threshold_ms#

The threshold in milliseconds that was exceeded.

Type:

int

player#

The player that the event was dispatched from.

Type:

Player

Callbacks#

mafic.on_websocket_closed()#

Called when the websocket connection from Lavalink is closed to Discord.

Parameters:

event (WebSocketClosedEvent) – The event that was dispatched.

mafic.on_track_start()#

Called when a track starts playing.

Parameters:

event (TrackStartEvent) – The event that was dispatched.

mafic.on_track_end()#

Called when a track ends.

Parameters:

event (TrackEndEvent) – The event that was dispatched.

mafic.on_track_exception()#

Called when a track throws an exception.

Parameters:

event (TrackExceptionEvent) – The event that was dispatched.

mafic.on_track_stuck()#

Called when a track gets stuck.

Parameters:

event (TrackStuckEvent) – The event that was dispatched.

mafic.on_node_stats()#

Called when Lavalink sends node statistics.

New in version 2.5.

Parameters:

node (Node) – The node that sent the statistics.

mafic.on_node_ready()#

Called when Lavalink node is ready.

Parameters:

node (Node) – The node that was ready.

mafic.on_node_unavailable()#

Called when Lavalink node becomes unavailable.

Parameters:

node (Node) – The node that became unavailable.