Skip to main content
https://raw.githubusercontent.com/Aspect1103/Lavapy/master/logo.png https://img.shields.io/pypi/pyversions/Lavapy https://img.shields.io/pypi/v/Lavapy https://readthedocs.org/projects/lavapy/badge/?version=latest https://img.shields.io/github/license/Aspect1103/Lavapy https://img.shields.io/lgtm/grade/python/g/Aspect1103/Lavapy.svg?logo=lgtm&logoWidth=18

A powerful and robust Python library built from the ground up for interacting with Lavalink.

IMPORTANT PSA: Future of this Library

The aim of this library was to provide a wrapper for lavalink when using discord.py. Before I started development, I was using a library called Wavelink, however, once it became archived I decided to start development on this library to not only improve my own skills but to help others with the same problem.

However, now my interest has started to falter. I have lost the drive to continue maintaining this library for a number of reasons: the code isn’t PEP 8 compliant unlike my newer projects and the code is hard to maintain in its current form. But the most important reason is that there is now a large number of alternative libraries which do this specific purpose much better than this library including but not limited to: Wavelink, Pomice, and Pycord.Wavelink.

Henceforth, I have made the decision to stop maintaining this library and leave it dormant. I won’t archive it as I may recover the drive I had when starting this project later on, but for now, the library is now inactive.

Installation

Lavapy requires Python 3.8 or higher

To install Lavapy, use one of the commands below:

# Windows
py -3.8 -m pip install -U lavapy

# Linux/macOS
python3.8 -m pip install -U lavapy

Then you need to setup the Lavalink server. For more details visit the faq.

Now all of that is done, you can start using Lavapy.

Usage

A simple and easy example to connect to a voice channel and play a Youtube song based on a given search query.

from discord.ext import commands
import lavapy

bot = commands.Bot(command_prefix="!")


async def initialiseNodes():
    """
    Wait until the bot is ready then create a Lavapy node
    """
    await bot.wait_until_ready()

    await lavapy.NodePool.createNode(client=bot,
                                     host="0.0.0.0",
                                     port=2333,
                                     password="LAVALINK_PASSWORD")


@bot.command()
async def play(ctx: commands.Context, *query) -> None:
    """
    Play a Youtube song from a given search query.

    If the bot is not connected, connect it to the user's voice channel. For this
    to work, the user must be connected to a voice channel
    """
    if not ctx.voice_client:
        # Bot is not connected to a voice channel
        try:
            player: lavapy.Player = await ctx.author.voice.channel.connect(cls=lavapy.Player)
        except AttributeError:
            # User is not connected to a voice channel
            await ctx.channel.send("You must be connected to a voice channel")
            return
    else:
        # Bot is connected to a voice channel
        player: lavapy.Player = ctx.voice_client

    # Get tracks based on the given search query
    track = await lavapy.YoutubeTrack.search(" ".join(query), player.node)
    await player.play(track)


bot.loop.create_task(initialiseNodes())
bot.run("BOT_TOKEN")

Release files for Lavapy 1.6.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 Lavapy 1.6.1
File Size Uploaded
Lavapy-1.6.1.tar.gz 24.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Lavapy 1.6.1
File Interpreter ABI Platform
Lavapy-1.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 63.4 kB

Release files / Lavapy-1.6.1.tar.gz

Download URL Lavapy-1.6.1.tar.gz
Size 24.9 kB
Tags Source
SHA-256 checksum
How to use checksums
342fd6fc85d955857bcd5d2eac9d81e486f0fd5659ef755493fc68fb82eed08a
BLAKE2b-256 checksum
How to use checksums
87fae0fe589664d795e7f3987b9cbcb6d9526f9dd58022f0ec16e6d50267adf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.12

Release files / Lavapy-1.6.1-py3-none-any.whl

Download URL Lavapy-1.6.1-py3-none-any.whl
Size 38.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd1a8c558841652fee393a585dd031be044824e561c92356c65bf74c36cf1a1b
BLAKE2b-256 checksum
How to use checksums
56cb588a57cbf9fafcea69b2f6546495a6f818ede2b9ef5626e55b147990dc03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.12

Release history Release notifications | RSS feed

This release

1.6.1 This release

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

1 release file

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