Git Product home page Git Product logo

granitepy's Introduction

granitepy

granitepy is a python wrapper for the Lavalink like audio provider called Andesite for use with discord.py.

Links

Installation

From Pypi

pip install -U granitepy

From Github

pip install -U git+https://github.com/iDevision/granitepy

Example

from discord.ext import commands
import granitepy

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

@bot.event
async def on_ready():
    await bot.granitepy.create_node(
        host="node-ip",
        port=12345,
        password="node-password",
        identifier="node-name"
    )

@bot.command()
async def connect(ctx):
    # Create or fetch a player.
    player = bot.granitepy.get_player(guild=ctx.guild)

    # Check is the author is in a voice channel.
    if not ctx.author.voice:
        return await ctx.send("You must be connected to a voice channel")

    # Connect to the authors voice channel.
    await player.connect(ctx.author.voice.channel)
    return await ctx.send(f"Connected to {ctx.author.voice.channel.name}!")

@bot.command()
async def play(ctx, *, search):
    player = bot.granitepy.get_player(guild=ctx.guild)

    # Search for whatever the user has inputted.
    result = await player.get_tracks(search)

    # The users search returned nothing.
    if not result:
        return await ctx.send("No tracks were found.")

    # Check if the result is a playlist.
    if isinstance(result, granitepy.Playlist):
        # Play the first track in the playlist.
        return await player.play(result.tracks[0])
    else:
        # Play the first track in the list of results.
        return await player.play(result[0])

bot.run("token")

granitepy's People

Contributors

idutchy avatar twitch0001 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

idutchy

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.