pylav.events package#

Subpackages#

Submodules#

pylav.events.base module#

class pylav.events.base.PyLavEvent[source]#

Bases: object

The base for all Lavalink events

pylav.events.manager module#

class pylav.events.manager.DispatchManager(client)[source]#

Bases: object

The Dispatcher is responsible for dispatching events to the appropriate handlers.

The method names are the event names.

You can listen to events by adding the following to your client:

Examples

>>> from discord.ext import commands
>>> @commands.Cog.listener()
>>> async def on_pylav_queue_end_event(self, event: queue.QueueEndEvent):
>>>    print(f"Queue ended: {event.player.guild.name}")
>>> @commands.Cog.listener()
>>> async def on_pylav_track_stuck_event(self, event: track.TrackStuckEvent):
>>>    print(f"Track got stuck: {event.track.encoded}")
async dispatch(event)[source]#

Dispatches an event to the appropriate handler

dispatcher#
get_event_names()[source]#

Returns a set of all event names

Returns:

A set of all event names prefixed with pylav_

Return type:

set[str]

mapping#
simple_event_names()[source]#

Returns a set of all simple event names

Returns:

A set of all event names

Return type:

set[str]

pylav.events.node module#

class pylav.events.node.NodeChangedEvent(player, old_node, new_node)[source]#

Bases: PyLavEvent

This event is dispatched when a player changes to another node. Keep in mind this event can be dispatched multiple times if a node disconnects and the load balancer moves players to a new node.

Event can be listened to by adding a listener with the name pylav_node_changed_event.

player#

The player that changed nodes.

Type:

Player

old_node#

The node the player was on before the change.

Type:

Node

new_node#

The node the player is on after the change.

Type:

Node

new_node#
old_node#
player#
class pylav.events.node.NodeConnectedEvent(node)[source]#

Bases: PyLavEvent

This event is dispatched when PyLav successfully connects to a node.

Event can be listened to by adding a listener with the name pylav_node_connected_event.

node#

The node that connected.

Type:

Node

node#
class pylav.events.node.NodeDisconnectedEvent(node, code, reason)[source]#

Bases: PyLavEvent

This event is dispatched when a node disconnects and becomes unavailable.

Event can be listened to by adding a listener with the name pylav_node_disconnected_event.

node#

The node that disconnected.

Type:

Node

code#

The close code.

Type:

int

reason#

The close reason.

Type:

str

code#
node#
reason#
class pylav.events.node.WebSocketClosedEvent(player, node, channel, event_object)[source]#

Bases: PyLavEvent

This event is dispatched when an audio websocket to Discord is closed. This can happen for various reasons like an expired voice server update.

Event can be listened to by adding a listener with the name pylav_websocket_closed_event.

player#

The player whose websocket was closed.

Type:

Player

node#

The node the player is on.

Type:

Node

channel#

The channel the player is in.

Type:

discord.channel.VocalGuildChannel

code#

The close code.

Type:

int

reason#

The close reason.

Type:

str

by_remote#

Whether the close was initiated by Discord or not.

Type:

bool

event#

The received event object.

Type:

Closed

by_remote#
channel#
code#
event#
node#
player#
reason#

pylav.events.player module#

class pylav.events.player.FiltersAppliedEvent(player, requester, node, volume=None, equalizer=None, karaoke=None, timescale=None, tremolo=None, vibrato=None, rotation=None, distortion=None, low_pass=None, channel_mix=None, echo=None, pluginFilters=None)[source]#

Bases: PyLavEvent

This event is dispatched when filters are applied.

Event can be listened to by adding a listener with the name filters_applied_event.

player#

The player that had filters applied.

Type:

Player

requester#

The member that requested the filters to be applied.

Type:

discord.Member

volume#

The volume filter.

Type:

Volume | None

equalizer#

The equalizer filter.

Type:

Equalizer | None

karaoke#

The karaoke filter.

Type:

Karaoke | None

timescale#

The timescale filter.

Type:

Timescale | None

tremolo#

The tremolo filter.

Type:

Tremolo | None

vibrato#

The vibrato filter.

Type:

Vibrato | None

rotation#

The rotation filter.

Type:

Rotation | None

distortion#

The distortion filter.

Type:

Distortion | None

low_pass#

The low pass filter.

Type:

LowPass | None

channel_mix#

The channel mix filter.

Type:

ChannelMix | None

echo#

The echo filter.

Type:

Echo | None

channel_mix#
distortion#
echo#
equalizer#
karaoke#
low_pass#
player#
pluginFilters#
requester#
rotation#
timescale#
tremolo#
vibrato#
volume#
class pylav.events.player.PlayerAutoDisconnectedAloneEvent(player)[source]#

Bases: PyLavEvent

This event is dispatched when the player is auto disconnected due to it being alone in the voice channel.

Event can be listened to by adding a listener with the name player_auto_disconnected_alone_event.

player#

The player that was auto disconnected.

Type:

Player

requester#

The member that requested the player to be auto disconnected.

Type:

discord.Member

current_track#

The current track that was playing.

Type:

Track | None

position#

The position of the current track.

Type:

float

queue#

The queue of the player when it was auto disconnected.

Type:

collections.deque[Track]

current_track#
player#
position#
queue#
requester#
class pylav.events.player.PlayerAutoDisconnectedEmptyQueueEvent(player)[source]#

Bases: PyLavEvent

This event is dispatched when the player is auto disconnected due to an empty queue.

Event can be listened to by adding a listener with the name player_auto_disconnected_empty_queue_event.

player#

The player that was auto disconnected.

Type:

Player

requester#

The member that requested the player to be auto disconnected.

Type:

discord.Member

current_track#

The current track that was playing.

Type:

Track | None

position#

The position of the current track.

Type:

float

queue#

The queue of the player when it was auto disconnected.

Type:

collections.deque[Track]

current_track#
player#
position#
queue#
requester#
class pylav.events.player.PlayerAutoPausedEvent(player)[source]#

Bases: PyLavEvent

This event is dispatched when the player is auto paused.

Event can be listened to by adding a listener with the name player_auto_paused_event.

player#

The player that was auto paused.

Type:

Player

requester#

The member that requested the player to be auto paused.

Type:

discord.Member

player#
requester#
class pylav.events.player.PlayerAutoResumedEvent(player)[source]#

Bases: PyLavEvent

This event is dispatched when the player is auto resumed.

Event can be listened to by adding a listener with the name player_auto_resumed_event.

player#

The player that was auto resumed.

Type:

Player

requester#

The member that requested the player to be auto resumed.

Type:

discord.Member

player#
requester#
class pylav.events.player.PlayerConnectedEvent(player, requester)[source]#

Bases: PyLavEvent

This event is dispatched when the player is connected.

Event can be listened to by adding a listener with the name pylav_player_connected_event.

player#

The player that was connected.

Type:

Player

requester#

The member that requested the connect.

Type:

discord.Member | None

player#
requester#
class pylav.events.player.PlayerDisconnectedEvent(player, requester)[source]#

Bases: PyLavEvent

This event is dispatched when the player is disconnected.

Event can be listened to by adding a listener with the name pylav_player_disconnected_event.

player#

The player that was disconnected.

Type:

Player

requester#

The member that requested the disconnect.

Type:

discord.Member

current_track#

The current track that was playing when the player was disconnected.

Type:

Track | None

position#

The position of the current track when the player was disconnected.

Type:

float

queue#

The queue of the player when the player was disconnected.

Type:

collections.deque[Track]

current_track#
player#
position#
queue#
requester#
class pylav.events.player.PlayerMovedEvent(player, requester, before, after)[source]#

Bases: PyLavEvent

This event is dispatched when the player is moved.

Event can be listened to by adding a listener with the name pylav_player_moved_event.

player#

The player that was moved.

Type:

Player

requester#

The member that requested the move.

Type:

discord.Member

before#

The channel the player was in before the move.

Type:

discord.channel.VocalGuildChannel

after#

The channel the player is in after the move.

Type:

discord.channel.VocalGuildChannel

after#
before#
player#
requester#
class pylav.events.player.PlayerPausedEvent(player, requester)[source]#

Bases: PyLavEvent

This event is dispatched when a player is paused.

Event can be listened to by adding a listener with the name pylav_player_paused_event.

player#

The player that was paused.

Type:

Player

requester#

The member that requested the pause.

Type:

discord.Member

player#
requester#
class pylav.events.player.PlayerRepeatEvent(player, requester, op_type, queue_before, queue_after, current_before, current_after)[source]#

Bases: PyLavEvent

This event is dispatched when the player repeat config changed.

Event can be listened to by adding a listener with the name pylav_player_repeat_event.

player#

The player that had its repeat config changed.

Type:

Player

requester#

The member that requested the repeat change.

Type:

discord.Member

type#

The type of operation that was performed, “current” or “queue”

Type:

str

queue_before#

The queue repeat state before the operation.

Type:

bool

queue_after#

The queue repeat state after the operation.

Type:

bool

current_before#

The current track repeat state before the operation.

Type:

bool

current_after#

The current track repeat state after the operation.

Type:

bool

current_after#
current_before#
player#
queue_after#
queue_before#
requester#
type#
class pylav.events.player.PlayerRestoredEvent(player, requester)[source]#

Bases: PyLavEvent

This event is dispatched when a player is restored.

Event can be listened to by adding a listener with the name pylav_player_restored_event.

player#

The player that was restored.

Type:

Player

requester#

The member that requested the restore.

Type:

discord.Member

player#
requester#
class pylav.events.player.PlayerResumedEvent(player, requester)[source]#

Bases: PyLavEvent

This event is dispatched when a player is resumed.

Event can be listened to by adding a listener with the name pylav_player_resumed_event.

player#

The player that was resumed.

Type:

Player

requester#

The member that requested the resume.

Type:

discord.Member

player#
requester#
class pylav.events.player.PlayerStoppedEvent(player, requester)[source]#

Bases: PyLavEvent

This event is dispatched when a player is stopped.

Event can be listened to by adding a listener with the name pylav_player_stopped_event.

player#

The player that was stopped.

Type:

Player

requester#

The member that requested the stop.

Type:

discord.Member

player#
requester#
class pylav.events.player.PlayerUpdateEvent(player, position, timestamp)[source]#

Bases: PyLavEvent

This event is dispatched when the player’s progress changes.

Event can be listened to by adding a listener with the name pylav_player_update_event.

player#

The player that was updated.

Type:

Player

position#

The position of the player.

Type:

float

timestamp#

The timestamp of the event.

Type:

float

player#
position#
timestamp#
class pylav.events.player.PlayerVolumeChangedEvent(player, requester, before, after)[source]#

Bases: PyLavEvent

This event is dispatched when the player has its volume changed.

Event can be listened to by adding a listener with the name pylav_player_volume_changed_event.

player#

The player that had its volume changed.

Type:

Player

requester#

The member that requested the volume change.

Type:

discord.Member

before#

The volume before the change.

Type:

float

after#

The volume after the change.

Type:

float

after#
before#
player#
requester#
class pylav.events.player.QuickPlayEvent(player, requester, track)[source]#

Bases: PyLavEvent

This event is dispatched when a track is played with higher priority than the current track.

Event can be listened to by adding a listener with the name quick_play_event.

player#

The player that had a track played.

Type:

Player

requester#

The member that requested the track to be played.

Type:

discord.Member

track#

The track that was played.

Type:

Track

player#
requester#
track#

pylav.events.queue module#

class pylav.events.queue.QueueEndEvent(player)[source]#

Bases: PyLavEvent

This event is dispatched when there are no more songs in the queue.

Event can be listened to by adding a listener with the name pylav_queue_end_event.

player#

The player that has no more songs in queue.

Type:

Player

Parameters:

player (Player) – The player that has no more songs in queue.

player#
class pylav.events.queue.QueueShuffledEvent(player, requester)[source]#

Bases: PyLavEvent

This event is dispatched when the queue is shuffled.

Event can be listened to by adding a listener with the name pylav_queue_shuffled_event.

player#

The player whose queue was shuffled.

Type:

Player

requester#

The user who requested the change.

Type:

discord.Member

Parameters:
  • player (Player) – The player whose queue was shuffled.

  • requester (discord.Member) – The user who requested the change.

player#
requester#
class pylav.events.queue.QueueTrackPositionChangedEvent(player, before, after, requester, track)[source]#

Bases: PyLavEvent

This event is dispatched when the position of a track is changed.

Event can be listened to by adding a listener with the name pylav_queue_track_position_changed_event.

player#

The player whose track position was changed.

Type:

Player

before#

The position of the track before the change.

Type:

int

after#

The position of the track after the change.

Type:

int

requester#

The user who requested the change.

Type:

discord.Member

track#

The track whose position was changed.

Type:

Track

Parameters:
  • player (Player) – The player whose track position was changed.

  • before (int) – The position of the track before the change.

  • after (int) – The position of the track after the change.

  • requester (discord.Member) – The user who requested the change.

  • track (Track) – The track whose position was changed.

after#
before#
player#
requester#
track#
class pylav.events.queue.QueueTracksAddedEvent(player, requester, tracks)[source]#

Bases: PyLavEvent

This event is dispatched when a track in added to the queue.

Event can be listened to by adding a listener with the name pylav_queue_tracks_added_event.

player#

The player whose queue had tracks added to it.

Type:

Player

requester#

The user who requested the change.

Type:

discord.Member

tracks#

The tracks that were added to the queue.

Type:

list of Track

player#
requester#
tracks#
class pylav.events.queue.QueueTracksRemovedEvent(player, requester, tracks)[source]#

Bases: PyLavEvent

This event is dispatched when tracks are removed from the queue.

Event can be listened to by adding a listener with the name pylav_queue_tracks_removed_event.

player#

The player whose queue was shuffled.

Type:

Player

requester#

The user who requested the change.

Type:

discord.Member

tracks#

The tracks that were removed from the queue.

Type:

list of Track

Parameters:
  • player (Player) – The player whose queue was shuffled.

  • requester (discord.Member) – The user who requested the change.

  • tracks (list of Track) – The tracks that were removed from the queue.

player#
requester#
tracks#

pylav.events.utils module#

class pylav.events.utils.PluginInfoTypeHint(*, echo: 'Echo | None' = None)[source]#

Bases: object

echo#
pylav.events.utils.get_event_name(class_type)[source]#

Returns the event name for a given event class while prefixing it with pylav_.

pylav.events.utils.get_simple_event_name(class_type)[source]#

Returns the event name for a given event class.

pylav.events.utils.to_snake_case(name)[source]#

Converts a string to snake case.

Module contents#