lavalink_rs API documentation

# 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], connection_info: ConnectionInfo, 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]:
async def load_tracks( self, guild_id: Union[lavalink_rs.GuildId, int], identifier: str) -> Union[TrackData, PlaylistData, List[TrackData], TrackError, NoneType]:
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 set_queue_push_to_back(self, track: Union[lavalink_rs.TrackInQueue, TrackData]) -> None:
def set_queue_push_to_front(self, track: Union[lavalink_rs.TrackInQueue, TrackData]) -> None:
def set_queue_insert( self, position: int, track: Union[lavalink_rs.TrackInQueue, TrackData]) -> None:
def set_queue_remove(self, position: int) -> None:
def set_queue_clear(self) -> None:
def set_queue_replace( self, tracks: Sequence[Union[lavalink_rs.TrackInQueue, TrackData]]) -> None:
def set_queue_append( self, tracks: Sequence[Union[lavalink_rs.TrackInQueue, TrackData]]) -> None:
async def get_queue(self) -> List[lavalink_rs.TrackInQueue]:
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 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)
password: str
hostname: str
user_id: lavalink_rs.UserId
session_id: Optional[str]
is_ssl: bool
class NodeDistributionStrategy:
def new() -> Self:
def sharded() -> Self:
def round_robin() -> Self:
def main_fallback() -> Self:
def lowest_load() -> Self:
def highest_free_memory() -> Self:
def custom( func: Callable[[lavalink_rs.LavalinkClient, Union[lavalink_rs.GuildId, int]], Awaitable[int]]) -> Self:
class TrackInQueue:

A track that's inside the queue.

start_time_ms: Optional[int]
end_time_ms: Optional[int]
volume: Optional[int]
track: TrackData
filters: Optional[Filters]
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