Skip to main content
Documentation Status Code style: black

A Lavalink client library written for Python 3.8 using the AsyncIO framework. This library may be used for other projects as it contains no Red specific code or logic.

However, it is important to note that this library only supports projects using discord.py.

To install:

pip install red-lavalink

Usage

import lavalink
from discord.ext.commands import Bot


class MyBot(Bot):
    async def setup_hook(self):
        await lavalink.initialize(
            self, host='localhost', password='password', port=2333
        )


async def search_and_play(voice_channel, search_terms):
    player = await lavalink.connect(voice_channel)
    tracks = await player.search_yt(search_terms)
    player.add(tracks[0])
    await player.play()

Shuffling

def shuffle_queue(player_id, forced=True):
    player = lavalink.get_player(player_id)
    if not forced:
        player.maybe_shuffle(sticky_songs=0)
        """
        `player.maybe_shuffle` respects `player.shuffle`
        And will only shuffle if `player.shuffle` is True.

        `player.maybe_shuffle` should be called every time
        you would expect the queue to be shuffled.

        `sticky_songs=0` will shuffle every song in the queue.
        """
    else:
        player.force_shuffle(sticky_songs=3)
        """
        `player.force_shuffle` does not respect `player.shuffle`
        And will always shuffle the queue.

        `sticky_songs=3` will shuffle every song after the first 3 songs in the queue.
        """

When shutting down, be sure to do the following:

await lavalink.close(bot)

Release files for Red-Lavalink 0.11.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Red-Lavalink 0.11.1
File Size Uploaded
red_lavalink-0.11.1.tar.gz 34.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Red-Lavalink 0.11.1
File Interpreter ABI Platform
red_lavalink-0.11.1-py3-none-any.whl Python 3 none any Details

Total release size: 70.8 kB

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page