lavalink_rs API documentation

# lavalink_rs

class LavalinkClient:

The main client, where everything gets done, from events to requests to management.

def new(events, nodes, strategy, user_data=None):

The type of the None singleton.

def create_player_context(self, /, guild_id, endpoint, token, session_id, user_data=None):

The type of the None singleton.

def create_player(self, /, guild_id, endpoint, token, session_id):

The type of the None singleton.

def get_player_context(self, /, guild_id):

The type of the None singleton.

def get_node_by_index(self, /, idx):

The type of the None singleton.

def get_node_for_guild(self, /, guild_id):

The type of the None singleton.

def load_tracks(self, /, guild_id, identifier):

The type of the None singleton.

def delete_player(self, /, guild_id):

The type of the None singleton.

def delete_all_player_contexts(self, /):

The type of the None singleton.

def update_player(self, /, guild_id, update_player, no_replace):

The type of the None singleton.

def decode_track(self, /, guild_id, track):

The type of the None singleton.

def decode_tracks(self, /, guild_id, tracks):

The type of the None singleton.

def request_version(self, /, guild_id):

The type of the None singleton.

def request_info(self, /, guild_id):

The type of the None singleton.

def request_stats(self, /, guild_id):

The type of the None singleton.

def request_player(self, /, guild_id):

The type of the None singleton.

def request_all_players(self, /, guild_id):

The type of the None singleton.

def handle_voice_server_update(self, /, guild_id, token, endpoint):

The type of the None singleton.

def handle_voice_state_update(self, /, guild_id, channel_id, user_id, session_id):

The type of the None singleton.

def get_connection_info(self, /, guild_id, timeout):

The type of the None singleton.

data
class PlayerContext:

The player context.

def get_queue(self, /):

The type of the None singleton.

def get_player(self, /):

The type of the None singleton.

def update_player(self, /, update_player, no_replace):

The type of the None singleton.

def play(self, /, track):

The type of the None singleton.

def play_now(self, /, track):

The type of the None singleton.

def stop_now(self, /):

The type of the None singleton.

def set_pause(self, /, pause):

The type of the None singleton.

def set_volume(self, /, volume):

The type of the None singleton.

def set_filters(self, /, filters):

The type of the None singleton.

def set_position_ms(self, /, position):

The type of the None singleton.

def queue(self, /, track):

The type of the None singleton.

def close(self, /):

The type of the None singleton.

def skip(self, /):

The type of the None singleton.

def finish(self, /, should_continue):

The type of the None singleton.

def update_player_data(self, /, player):

The type of the None singleton.

data
class EventHandler:
def stats(self, client, session_id, event, /):

Periodic event that returns the statistics of the server.

def player_update(self, client, session_id, event, /):

Event that triggers when a player updates.

def track_start(self, client, session_id, event, /):

Event that triggers when a track starts playing.

def track_end(self, client, session_id, event, /):

Event that triggers when a track finishes playing.

def track_exception(self, client, session_id, event, /):

Event that triggers when a track raises an exception on the Lavalink server.

def track_stuck(self, client, session_id, event, /):

Event that triggers when a track gets stuck while playing.

def websocket_closed(self, client, session_id, event, /):

Event that triggers when the websocket connection to the voice channel closes.

def ready(self, client, session_id, event, /):

Event that triggers when the connection is ready.

class Http:
def request(self, /, method, uri, data):

The type of the None singleton.

def raw_request(self, /, method, uri, data):

The type of the None singleton.

def delete_player(self, /, guild_id, session_id):

Destroys the player for this guild in this session.

def update_player(self, /, guild_id, session_id, data, no_replace):

Updates or creates the player for this guild.

def set_resuming_state(self, /, session_id, resuming_state):

Updates the session with the resuming state and timeout.

def load_tracks(self, /, identifier):

Resolves audio tracks for use with the `update_player` endpoint.

# Parameters

- `identifier`: A track identifier.
  - Can be a url: "https://youtu.be/watch?v=DrM2lo6B04I"
  - A unique identifier: "DrM2lo6B04I"
  - A search: "ytsearch:Ne Obliviscaris - Forget Not"

def version(self, /):

Request Lavalink server version.

def stats(self, /):

Request Lavalink statistics.

NOTE: The frame stats will never be returned.

def info(self, /):

Request Lavalink server information.

def decode_track(self, /, track):

Decode a single track into its info.

# Parameters

- `track`: base64 encoded track data.

def decode_tracks(self, /, tracks):

Decode multiple tracks into their info.

# Parameters

- `tracks`: base64 encoded tracks.

def get_player(self, /, guild_id, session_id):

Returns the player for this guild in this session.

def get_players(self, /, session_id):

Returns a list of players in this specific session.

rest_address
rest_address_versionless
authority
class Node:
http
class NodeBuilder:

A builder for the node.

# Example

    # use crate::model::UserId;
    let node_builder = NodeBuilder {
        hostname: "localhost:2333".to_string(),
        password: "youshallnotpass".to_string(),
        user_id: UserId(551759974905151548),
        ..Default::default()
    };

hostname
password
user_id
is_ssl
session_id
class NodeDistributionStrategy:
def sharded():

The type of the None singleton.

def round_robin():

The type of the None singleton.

def main_fallback():

The type of the None singleton.

def lowest_load():

The type of the None singleton.

def highest_free_memory():

The type of the None singleton.

def custom(func):

The type of the None singleton.

class TrackInQueue:

A track that's inside the queue.

start_time_ms
filters
volume
track
end_time_ms
class QueueRef:

A reference to the player queue

def get_queue(self, /):

The type of the None singleton.

def get_track(self, /, index):

The type of the None singleton.

def get_count(self, /):

The type of the None singleton.

def push_to_back(self, /, track):

The type of the None singleton.

def push_to_front(self, /, track):

The type of the None singleton.

def insert(self, /, index, track):

The type of the None singleton.

def remove(self, /, index):

The type of the None singleton.

def clear(self, /):

The type of the None singleton.

def replace(self, /, tracks):

The type of the None singleton.

def append(self, /, tracks):

The type of the None singleton.

def swap(self, /, index, track):

The type of the None singleton.

class UserId:

A discord User ID.

inner
class ChannelId:

A discord Channel ID.

inner
class GuildId:

A discord Guild ID.

inner