API Reference¶
Utility and Miscellaneous¶
Event Reference¶
Payloads¶
- class wavelink.NodeReadyPayload(node: Node, *, data: ReadyMsgT)¶
- class wavelink.NodeStatsPayload(node: Node, *, data: StatsData)¶
- class wavelink.PlayerUpdatePayload(node: Node, *, data: PlayerUpdateMsgT)¶
- class wavelink.TrackEndPayload(node: Node, *, data: TrackEndEventT)¶
- class wavelink.TrackExceptionPayload(node: Node, *, data: TrackExceptionEventT)¶
- class wavelink.TrackStartPayload(node: Node, *, data: TrackStartEventT | TrackEndEventT | TrackStuckEventT | TrackExceptionEventT)¶
- class wavelink.TrackStuckPayload(node: Node, *, data: TrackStuckEventT)¶
- class wavelink.WebsocketClosedPayload(node: Node, *, data: WebSocketClosedEventT)¶
Strategy Helpers¶
Enums¶
- class wavelink.AutoPlay(*values)¶
…
- class wavelink.EventType(*values)¶
enum.StrEnumrepresenting the event types dispatched via the Websocket.- TrackStart¶
- Type:
Literal[“track_start”]
- TrackEnd¶
- Type:
Literal[“track_end”]
- TrackException¶
- Type:
Literal[“track_exception”]
- TrackStuck¶
- Type:
Literal[“track_stuck”]
- WebsocketClosed¶
- Type:
Literal[“websocket_closed”]
- PlayerUpdate¶
- Type:
Literal[“player_update”]
- NodeStats¶
- Type:
Literal[“node_stats”]
- NodeReady¶
- Type:
Literal[“node_ready”]
- class wavelink.LoadResult(*values)¶
enum.StrEnumrepresenting the load result from the /loadtracks endpoint.
- class wavelink.Source(*values)¶
enum.StrEnumrepresenting a music source to search from. E.g. Youtube or Spotify.- youtube¶
Source representing Youtube.
- Type:
Literal[“ytsearch”]
- youtube_music¶
A source representing Youtube Music.
- Type:
Literal[“ytmsearch”]
- soundcloud¶
A source representing SoundCloud.
- Type:
Literal[“scsearch”]
- spotify¶
A source representing Spotify.
- Type:
Literal[“spsearch”]
- local¶
A source representing a raw or local search. E.g. a URL or File Path.
- Type:
Literal[“local”]
- class wavelink.TrackEndReason(*values)¶
enum.StrEnumrepresenting the Track End Reason received by Lavalink.
Core¶
Music Bot¶
Nodes¶
Player¶
- asyncconnect
- asyncdisconnect
- asyncon_voice_server_update
- asyncon_voice_state_update
- class wavelink.Player(client: Client, channel: Connectable, /, *, node: Node | None = None)¶
Wavelink Player class which inherits from your libraries
VoiceProtocol.The
Playerclass is usually not constructed manually, instead you pass it to your librarieschannel.connect(cls=wavelink.Player)method instead; e.g.discord.VoiceChannel.connect().Since the
Playerrequires aNode, there are a few options available to allowPlayerto work.Use
MusicBot. This will automatically pass the bestNodeto this player.Use
Pooland assign it to yourClientas the.waveattribute. This will automatically pass the bestNodeto this player.Use either
Poolor a standaloneNodeand pass that todiscord.VoiceChannel.connect(). This will construct aPlayerfor you based on what you provide. e.g.Channel.connect(cls=self.node)
Players are unique to each
discord.Guild. You may only have onePlayerconnected perdiscord.Guildat any given time.The
Playerwill automatically attempt to re-establish connection to discord in cases where disconnection was not intended. You should not and do not need to implement re-connection logic on this class. Doing so may interfere or conflict with the internal logic. If you would like to implement you own activity/inactivity checks on this player, please refer toinactivity_strategy.Note
Any
MusicBot,PoolorNodecan be passed todiscord.VoiceChannel.connect()to create aPlayerand assign it an appropriateNode.- Parameters:
client (
discord.Client) – Thediscord.Clientcurrently running.channel (
discord.Connectable) – The voice channel thisPlayerhas connected to.node (
Node|None) – An optionalNodeto pass to use for thisPlayer. Defaults toNone. See above for more details.
- property node: Node¶
Property returning the
Nodeassociated with the player.- Return type:
Node
- property volume: int¶
Property returning the current volume of the player. Defaults to
100.- Return type:
- property ping: int¶
Property returning the ping of Lavalink to Discord.
If the ping is
-1the player is disconnected.- Return type:
- property last_update: datetime | None¶
Property return the datetime the player was last updated via Lavalink.
Could be
Noneif the player has not been updated.- Returns:
datetime.datetime – The time the player was last updated.
None – The player has not been updated.
- property is_playing: bool¶
Property returning a
boolindicating whether the player is currently playing a track.Note
Pausing the player has no effect on this property.
- Return type:
- property is_paused: bool¶
Property returning a
boolindicating whether the player is currently paused.- Return type:
- property is_deaf: bool¶
Property returning a
boolindicating whether the player is currently self deafened.- Return type:
- property is_mute: bool¶
Property returning a
boolindicating whether the player is self muted.Note
This is not the same as turning down the volume to
0.- Return type:
- await on_voice_server_update(data: VoiceServerUpdatePayload) None¶
This function is a coroutine.
An abstract method that is called when initially connecting to voice. This corresponds to
VOICE_SERVER_UPDATE.- Parameters:
data (
dict) – The raw voice server update payload.
- await on_voice_state_update(data: GuildVoiceStatePayload) None¶
This function is a coroutine.
An abstract method that is called when the client’s voice state has changed. This corresponds to
VOICE_STATE_UPDATE.Warning
This method is not the same as the event. See:
on_voice_state_update()- Parameters:
data (
dict) – The raw voice state payload.
- await connect(*, timeout: float = 10.0, reconnect: bool = True, self_deaf: bool = False, self_mute: bool = False) None¶
This function is a coroutine.
An abstract method called when the client initiates the connection request.
When a connection is requested initially, the library calls the constructor under
__init__and then callsconnect(). Ifconnect()fails at some point thendisconnect()is called.Within this method, to start the voice connection flow it is recommended to use
Guild.change_voice_state()to start the flow. After which,on_voice_server_update()andon_voice_state_update()will be called. The order that these two are called is unspecified.