A python client for the audio provider Andesite for use with discord.py.
Project description
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")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
granitepy-0.4.1.tar.gz
(11.4 kB
view hashes)
Built Distribution
granitepy-0.4.1-py3-none-any.whl
(24.5 kB
view hashes)
Close
Hashes for granitepy-0.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc02da828ca1f8eaea2b23e4d0cac7a0ea07347419ebb8624b0b0bae078c76e5 |
|
MD5 | 7ea42fb832c335ba9d0b5548c5a1f829 |
|
BLAKE2b-256 | e91309e9f71dbeec78f4f282937e6de875c9a0f2ad25d933e8a6c4d55a079b04 |