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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: nextlava-1.4.1b4.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.1b4.tar.gz
Algorithm Hash digest
SHA256 ceb131c0858488b6927be572ece4a1d36e24539a0f269ffcb2c66c346db54b07
MD5 8ab7abf971e7b02d8f9e3b645bde0d30
BLAKE2b-256 910f0e91f46de9ae11c6da2ed51c456afe43e913f4f5e4b9f22b94432caaed50

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nextlava-1.4.1b4-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.1b4-py3-none-any.whl
Algorithm Hash digest
SHA256 d95a8070afc9d6b7943d5805871cbc12f13fd1bc7ee7bbfa030dd51f1521014f
MD5 1728421f29919edc18acb9532abe8fb9
BLAKE2b-256 4c285e14a3f39234a06eb3b006e4f10d314c8f48762f64f76d1bbde6022a7852

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