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.1b2.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file nextlava-1.4.1b2.tar.gz.

File metadata

  • Download URL: nextlava-1.4.1b2.tar.gz
  • Upload date:
  • Size: 24.9 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.1b2.tar.gz
Algorithm Hash digest
SHA256 124acb9e1cadbecb66437199537e9b1a37e466c081e70e0c24e26d7c46fd0400
MD5 5047c8481a4ee8ad341aae4d2f483ce5
BLAKE2b-256 1756d13609dcbfd99af515d0500f2f627a2e6ddddfbb666b9c313e0fdaa163b0

See more details on using hashes here.

File details

Details for the file nextlava-1.4.1b2-py3-none-any.whl.

File metadata

  • Download URL: nextlava-1.4.1b2-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.1b2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f82346de748a74f059ae2a47c013729e9d5f331cde6cb0e26e19c49ac5277bf
MD5 a795cdcc0de3a8bbeb6ea3c0f023b823
BLAKE2b-256 d1e29fcc71fff9fa6e2a6cf98136ee06502f948a7eb4574c6a380a8b795e2c3d

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