Node¶
A Node represents a single Lavalink server connection managed by the Pool.
Create Node instances and pass them to Pool.connect() — you do not connect them directly.
Guide
See the Node & Pool Guide for usage patterns and multi-node setup.
Node ¶
Node(
*,
identifier: str | None = None,
uri: str,
password: str,
session: ClientSession | None = None,
heartbeat: float = 15.0,
retries: int | None = None,
client: Client | None = None,
resume_timeout: int = 60,
inactive_player_timeout: int | None = 300,
inactive_channel_tokens: int | None = 3,
region: str | None = None,
)
The Node represents a connection to Lavalink.
The Node is responsible for keeping the websocket alive, resuming session,
sending API requests and keeping track of connected all :class:~revvlink.Player.
node == otherEquality check to determine whether this Node is equal to another reference of a Node.repr(node)The official string representation of this Node.Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str | None
|
A unique identifier for this Node. Could be |
None
|
uri
|
str
|
|
required |
password
|
str
|
The password used to connect and authorize this Node. |
required |
session
|
ClientSession | None
|
An optional :class: |
None
|
heartbeat
|
float
|
A |
15.0
|
retries
|
int | None
|
A |
None
|
client
|
Client | None
|
The :class: |
None
|
resume_timeout
|
int
|
The seconds this Node should configure Lavalink for resuming its current
session in case of network issues. If this is |
60
|
inactive_player_timeout
|
int | None
|
Set the default for :attr: |
300
|
inactive_channel_tokens
|
int | None
|
Sets the default for :attr: |
3
|
region
|
str | None
|
An optional string representing the node's region (e.g. "us", "eu", "asia").
Used for regional load balancing. Defaults to See also: :func: |
None
|
headers
property
¶
A property that returns the headers configured for sending API and websocket requests.
This includes your Node password. Please be vigilant when using this property.
status
property
¶
The current :class:Node status.
Refer to: :class:~revvlink.NodeStatus
penalty
property
¶
The composite load score for this node. Lower is better.
Used by :meth:Pool.get_node to rank nodes within a region or globally.
Components: - CPU system load (weighted exponentially) - Active player count (flat cost per player) - Frame deficit (huge penalty — indicates audio stuttering)
Returns:
| Type | Description |
|---|---|
float
|
The calculated penalty score. |
players
property
¶
A mapping of :attr:discord.Guild.id to :class:~revvlink.Player.
Returns:
| Type | Description |
|---|---|
dict[int, :class:`~revvlink.Player`]
|
A shallow copy of the internal players mapping. |
client
property
¶
The :class:discord.Client associated with this :class:Node.
Returns:
| Type | Description |
|---|---|
class:`discord.Client` | None
|
The client instance, or |
password
property
¶
The password used to connect and authorize this :class:Node to Lavalink.
Returns:
| Type | Description |
|---|---|
str
|
The node password. |
heartbeat
property
¶
The duration in seconds between WebSocket heartbeat pings.
Returns:
| Type | Description |
|---|---|
float
|
The heartbeat interval in seconds. |
session_id
property
¶
The Lavalink session ID for this node connection.
Returns:
| Type | Description |
|---|---|
str | None
|
The session ID, or |
info
property
¶
Returns the cached node info including source managers and plugins.
This property returns a :class:NodeInfo dataclass with convenience methods
for checking available sources and plugins.
Could be None if the node has not fetched info yet.
Use :meth:refresh_info to fetch the latest info.
Returns:
| Type | Description |
|---|---|
NodeInfo | None
|
The node info, or None if not yet fetched. |
refresh_info
async
¶
Fetch and cache the latest node info from Lavalink.
This method updates the cached info with the latest data from the Lavalink server, including available source managers and plugins.
Returns:
| Type | Description |
|---|---|
NodeInfo
|
The updated node info. |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occurred while making this request to Lavalink, and Lavalink was unable to send any error information. |
close
async
¶
Method to close this Node and cleanup.
After this method has finished, the event on_revvlink_node_closed will be fired.
This method renders the Node websocket disconnected and disconnects all players.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
eject
|
bool
|
If |
False
|
failover
|
bool
|
If |
True
|
send
async
¶
send(
method: Method = "GET",
*,
path: str,
data: Any | None = None,
params: dict[str, Any] | None = None,
) -> Any
Method for making requests to the Lavalink node.
Usually you wouldn't use this method. Please use the built in methods of ~Node, ~Pool and Player, unless you need to send specific plugin data to Lavalink.
Using this method may have unwanted side effects on your players and/or nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
Method
|
The method to use when making this request. Available methods are "GET", "POST", "PATCH", "PUT", "DELETE" and "OPTIONS". Defaults to "GET". |
'GET'
|
path
|
str
|
The path to make this request to. E.g. "/v4/stats". |
required |
data
|
Any | None
|
The optional JSON data to send along with your request to Lavalink. This should be a dict[str, Any] and able to be converted to JSON. |
None
|
params
|
dict[str, Any] | None
|
An optional dict of query parameters to send with your request to Lavalink.
If you include your query parameters in the |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The response from Lavalink which will either be None, a str or JSON. |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
fetch_players
async
¶
Method to fetch the player information Lavalink holds for every connected player on this node.
This payload is not the same as the revvlink.Player class. This is the data received from Lavalink about the players.
Returns:
| Type | Description |
|---|---|
list[:class:`PlayerResponsePayload`]
|
A list of :class: |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
fetch_player_info
async
¶
Method to fetch the player information Lavalink holds for the specific guild.
This payload is not the same as the revvlink.Player class. This is the data received from Lavalink about the player. See: get_player
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id
|
int
|
The ID of the guild you want to fetch info for. |
required |
Returns:
| Type | Description |
|---|---|
class:`PlayerResponsePayload` | None
|
The :class: |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
decode_track
async
¶
Decode a single base64 encoded track string back into a :class:~revvlink.Playable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
str
|
The base64 encoded track string to decode. |
required |
Returns:
| Type | Description |
|---|---|
class:`~revvlink.Playable`
|
The decoded :class: |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
decode_tracks
async
¶
Decode a list of base64 encoded track strings back into a list of
:class:~revvlink.Playable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded
|
list[str]
|
A list of base64 encoded track strings to decode. |
required |
Returns:
| Type | Description |
|---|---|
list[:class:`~revvlink.Playable`]
|
The decoded list of :class: |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
get_routeplanner_status
async
¶
Fetch the RoutePlanner status for this Lavalink node.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
A dictionary containing the RoutePlanner status, or |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
unmark_failed_address
async
¶
Unmark a failed address in the RoutePlanner so it may be reused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address
|
str
|
The IP address to unmark as failed. |
required |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
unmark_all_failed_addresses
async
¶
Unmark all failed addresses in the RoutePlanner so they may be reused.
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
fetch_info
async
¶
Method to fetch this Lavalink Nodes info response data.
Returns:
| Type | Description |
|---|---|
class:`InfoResponsePayload`
|
The :class: |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
fetch_stats
async
¶
Method to fetch this Lavalink Nodes stats response data.
Returns:
| Type | Description |
|---|---|
class:`StatsResponsePayload`
|
The :class: |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
fetch_version
async
¶
Method to fetch this Lavalink version string.
Returns:
| Type | Description |
|---|---|
str
|
The version string associated with this Lavalink node. |
Raises:
| Type | Description |
|---|---|
LavalinkException
|
An error occurred while making this request to Lavalink. |
NodeException
|
An error occured while making this request to Lavalink, and Lavalink was unable to send any error information. |
get_player ¶
Return a :class:~revvlink.Player associated with the
provided :attr:discord.Guild.id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
guild_id
|
int
|
The :attr: |
required |
Returns:
| Type | Description |
|---|---|
Optional[:class:`~revvlink.Player`]
|
The Player associated with this guild ID. Could be None if no
:class: |