Skip to main content

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

Project description

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.

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 nextlava

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

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 (nextcord version). Don’t need to uninstall discord.py.

Usage

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

from nextcord.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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nextlava-1.4.2.tar.gz (24.8 kB view details)

Uploaded Source

Built Distribution

nextlava-1.4.2-py3-none-any.whl (37.8 kB view details)

Uploaded Python 3

File details

Details for the file nextlava-1.4.2.tar.gz.

File metadata

  • Download URL: nextlava-1.4.2.tar.gz
  • Upload date:
  • Size: 24.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12

File hashes

Hashes for nextlava-1.4.2.tar.gz
Algorithm Hash digest
SHA256 44b91ecacb4fe969ea523653d1566dd4d77af59b63e8ec2b19538a782917457f
MD5 7eda7da6fe5bc1e9f4057dff4ed3358a
BLAKE2b-256 1fa99c6230d063b133f3959c0ebeaf228f43dd2ef2a6ab7e014a769aff989f90

See more details on using hashes here.

File details

Details for the file nextlava-1.4.2-py3-none-any.whl.

File metadata

  • Download URL: nextlava-1.4.2-py3-none-any.whl
  • Upload date:
  • Size: 37.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12

File hashes

Hashes for nextlava-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f7068c46381de2101ce7ff07fca784ce0acd2623b8c425319de228376b0bb366
MD5 828e0f44c52ae7d21f9bc6a46b4d2bd5
BLAKE2b-256 628831cc0720159df12f237cc9268bc6e526ecfd6481000458a7df69fdf466be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page