GithubHelp home page GithubHelp logo

lavapy's Introduction

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")

Links

lavapy's People

Contributors

jackashwell11 avatar rapptz avatar

Stargazers

Raϕ avatar コマリン親衛隊 avatar waeez avatar  avatar Atik avatar

Watchers

 avatar  avatar

Forkers

zekann rexwu1104

lavapy's Issues

self_mute is not defined

Newest commit changed argument names of the function Player.play, however the function still uses self_mute and self_deaf instead of selfMute and selfDeaf

Error:
File "...\Python310\lib\site-packages\lavapy\player.py", line 279, in connect
await self.guild.change_voice_state(channel=self.channel, self_mute=self_mute, self_deaf=self_deaf)

nextcord version?

Is it have nextcord version, because I get this error.
image

I change a little file of your package in here
can you update to nextcord version? please.

AttributeError: 'NoneType' object has no attribute '_getBearerToken'

I'm having a problem trying to create a node in lavapy.

Task exception was never retrieved
future: <Task finished name='Task-1' coro=<initialiseNodes() done, defined at C:\Users\Admin\Desktop\spaced_retention\testing discord.py:276> exception=AttributeError("'NoneType' object has no attribute '_getBearerToken'")>
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\spaced_retention\testing discord.py", line 282, in initialiseNodes
await lavapy.NodePool.createNode(client, "127.0.0.1", 2333, "youshallnotpass",identifier='TEST',region=discord.VoiceRegion.singapore)
File "I:\Python\Python310\lib\site-packages\lavapy\pool.py", line 135, in createNode
await node.spotifyClient._getBearerToken()
AttributeError: 'NoneType' object has no attribute '_getBearerToken'

Help is appreciated 👍🏿

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.