lavalink_rs

class LavalinkClient:

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

async def new( events: lavalink_rs.EventHandler, nodes: List[lavalink_rs.NodeBuilder], strategy: lavalink_rs.NodeDistributionStrategy, data: Optional[~__CD] = None) -> lavalink_rs.LavalinkClient:
async def create_player_context( self, guild_id: Union[lavalink_rs.GuildId, int], endpoint: str, token: str, session_id: str, data: Optional[~__PD] = None) -> lavalink_rs.PlayerContext:
async def create_player( self, guild_id: Union[lavalink_rs.GuildId, int], connection_info: ConnectionInfo) -> Player:
def get_player_context( self, guild_id: Union[lavalink_rs.GuildId, int]) -> Optional[lavalink_rs.PlayerContext]:
def get_node_by_index(self, idx: int) -> Optional[lavalink_rs.Node]:
async def get_node_for_guild(self, guild_id: Union[lavalink_rs.GuildId, int]) -> lavalink_rs.Node:
async def load_tracks( self, guild_id: Union[lavalink_rs.GuildId, int], identifier: str) -> Track:
async def delete_player(self, guild_id: Union[lavalink_rs.GuildId, int]) -> None:
async def delete_all_player_contexts(self) -> None:
async def update_player( self, guild_id: Union[lavalink_rs.GuildId, int], update_player: UpdatePlayer, no_replace: bool) -> Player:
async def decode_track(self, guild_id: Union[lavalink_rs.GuildId, int], track: str) -> TrackData:
async def decode_tracks( self, guild_id: Union[lavalink_rs.GuildId, int], tracks: List[str]) -> List[TrackData]:
async def request_version(self, guild_id: Union[lavalink_rs.GuildId, int]) -> str:
async def request_info(self, guild_id: Union[lavalink_rs.GuildId, int]) -> Info:
async def request_stats(self, guild_id: Union[lavalink_rs.GuildId, int]) -> Stats:
async def request_player(self, guild_id: Union[lavalink_rs.GuildId, int]) -> Player:
async def request_all_players(self, guild_id: Union[lavalink_rs.GuildId, int]) -> List[Player]:
def handle_voice_server_update( self, guild_id: Union[lavalink_rs.GuildId, int], token: str, endpoint: Optional[str]) -> None:
def handle_voice_state_update( self, guild_id: Union[lavalink_rs.GuildId, int], channel_id: Union[lavalink_rs.ChannelId, int, NoneType], user_id: Union[lavalink_rs.UserId, int], session_id: str) -> None:
async def get_connection_info( self, guild_id: Union[lavalink_rs.GuildId, int], timeout: int) -> ConnectionInfo:
data: Optional[~__CD]
class PlayerContext:

The player context.

def get_queue(self) -> lavalink_rs.QueueRef:
async def get_player(self) -> Player:
async def update_player(self, update_player: UpdatePlayer, no_replace: bool) -> Player:
async def play(self, track: TrackData) -> Player:
async def play_now(self, track: TrackData) -> Player:
async def stop_now(self) -> Player:
async def set_pause(self, pause: bool) -> Player:
async def set_volume(self, volume: int) -> Player:
async def set_filters(self, filters: Filters) -> Player:
async def set_position_ms(self, position: int) -> Player:
def queue(self, track: Union[lavalink_rs.TrackInQueue, TrackData]) -> None:
def close(self) -> None:
def skip(self) -> None:
def finish(self, should_continue: bool) -> None:
def update_player_data(self, player: Player) -> None:
data: Optional[~__PD]
class EventHandler:
async def stats( self, client: lavalink_rs.LavalinkClient, session_id: str, event: Stats) -> None:

Periodic event that returns the statistics of the server.

async def player_update( self, client: lavalink_rs.LavalinkClient, session_id: str, event: PlayerUpdate) -> None:

Event that triggers when a player updates.

async def track_start( self, client: lavalink_rs.LavalinkClient, session_id: str, event: TrackStart) -> None:

Event that triggers when a track starts playing.

async def track_end( self, client: lavalink_rs.LavalinkClient, session_id: str, event: TrackEnd) -> None:

Event that triggers when a track finishes playing.

async def track_exception( self, client: lavalink_rs.LavalinkClient, session_id: str, event: TrackException) -> None:

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

async def track_stuck( self, client: lavalink_rs.LavalinkClient, session_id: str, event: TrackStuck) -> None:

Event that triggers when a track gets stuck while playing.

async def websocket_closed( self, client: lavalink_rs.LavalinkClient, session_id: str, event: WebSocketClosed) -> None:

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

async def ready( self, client: lavalink_rs.LavalinkClient, session_id: str, event: Ready) -> None:

Event that triggers when the connection is ready.

class Http:
def request(self, /, method, uri, data):
def raw_request(self, /, method, uri, data):
async def delete_player(self, guild_id: Union[lavalink_rs.GuildId, int], session_id: str) -> None:

Destroys the player for this guild in this session.

async def update_player( self, guild_id: Union[lavalink_rs.GuildId, int], session_id: str, data: UpdatePlayer, no_replace: bool) -> Player:

Updates or creates the player for this guild.

async def set_resuming_state(self, session_id: str, resuming_state: ResumingState) -> ResumingState:

Updates the session with the resuming state and timeout.

async def load_tracks(self, identifier: str) -> Track:

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"
async def version(self) -> str:

Request Lavalink server version.

async def stats(self) -> Stats:

Request Lavalink statistics.

NOTE: The frame stats will never be returned.

async def info(self) -> Info:

Request Lavalink server information.

async def decode_track(self, track: str) -> TrackData:

Decode a single track into its info.

Parameters

  • track: base64 encoded track data.
async def decode_tracks(self, tracks: List[str]) -> List[TrackData]:

Decode multiple tracks into their info.

Parameters

  • tracks: base64 encoded tracks.
async def get_player( self, guild_id: Union[lavalink_rs.GuildId, int], session_id: str) -> Player:

Returns the player for this guild in this session.

async def get_players(self, session_id: str) -> List[Player]:

Returns a list of players in this specific session.

authority: str
rest_address: str
rest_address_versionless: str
class Node:
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()
};
NodeBuilder( hostname: str, is_ssl: bool, password: str, user_id: Union[lavalink_rs.UserId, int], session_id: Optional[str] = None, events: Optional[lavalink_rs.EventHandler] = None)
is_ssl: bool
password: str
session_id: Optional[str]
hostname: str
class NodeDistributionStrategy:
def round_robin() -> lavalink_rs.NodeDistributionStrategy:
def main_fallback() -> lavalink_rs.NodeDistributionStrategy:
def lowest_load() -> lavalink_rs.NodeDistributionStrategy:
def highest_free_memory() -> lavalink_rs.NodeDistributionStrategy:
def custom( func: Callable[[lavalink_rs.LavalinkClient, Union[lavalink_rs.GuildId, int]], Awaitable[lavalink_rs.Node]]) -> lavalink_rs.NodeDistributionStrategy:
class TrackInQueue:

A track that's inside the queue.

track: TrackData
end_time_ms: Optional[int]
start_time_ms: Optional[int]
volume: Optional[int]
filters: Optional[Filters]
class QueueRef:

A reference to the player queue

async def get_queue(self) -> List[lavalink_rs.TrackInQueue]:
async def get_track(self, index: int) -> Optional[lavalink_rs.TrackInQueue]:
async def get_count(self) -> int:
def push_to_back(self, track: Union[lavalink_rs.TrackInQueue, TrackData]) -> None:
def push_to_front(self, track: Union[lavalink_rs.TrackInQueue, TrackData]) -> None:
def insert( self, index: int, track: Union[lavalink_rs.TrackInQueue, TrackData]) -> None:
def remove(self, index: int) -> None:
def clear(self) -> None:
def replace( self, tracks: Sequence[Union[lavalink_rs.TrackInQueue, TrackData]]) -> None:
def append( self, tracks: Sequence[Union[lavalink_rs.TrackInQueue, TrackData]]) -> None:
def swap( self, index: int, track: Union[lavalink_rs.TrackInQueue, TrackData]) -> None:
class UserId:

A discord User ID.

UserId(id: int)
inner: int
class ChannelId:

A discord Channel ID.

ChannelId(id: int)
inner: int
class GuildId:

A discord Guild ID.

GuildId(id: int)
inner: int