A versatile LavaLink wrapper for Discord.py
Project description
A robust and powerful Lavalink wrapper for discord.py@rewrite!
Documentation
Support
For support using WaveLink, please join the official support server on Discord.
Installation
The following commands are currently the valid ways of installing WaveLink.
WaveLink requires Python 3.7+
Windows
py -3.7 -m pip install Wavelink
Linux
python3.7 -m pip install Wavelink
Getting Started
A quick and easy bot example:
import discord
import wavelink
from discord.ext import commands
class Bot(commands.Bot):
def __init__(self):
super(Bot, self).__init__(command_prefix=['audio ', 'wave ','aw '])
self.add_cog(Music(self))
async def on_ready(self):
print(f'Logged in as {self.user.name} | {self.user.id}')
class Music(commands.Cog):
def __init__(self, bot):
self.bot = bot
if not hasattr(bot, 'wavelink'):
self.bot.wavelink = wavelink.Client(self.bot)
self.bot.loop.create_task(self.start_nodes())
async def start_nodes(self):
await self.bot.wait_until_ready()
# Initiate our nodes. For this example we will use one server.
# Region should be a discord.py guild.region e.g sydney or us_central (Though this is not technically required)
await self.bot.wavelink.initiate_node(host='127.0.0.1',
port=2333,
rest_uri='http://127.0.0.1:2333',
password='youshallnotpass',
identifier='TEST',
region='us_central')
@commands.command(name='connect')
async def connect_(self, ctx, *, channel: discord.VoiceChannel=None):
if not channel:
try:
channel = ctx.author.voice.channel
except AttributeError:
raise discord.DiscordException('No channel to join. Please either specify a valid channel or join one.')
player = self.bot.wavelink.get_player(ctx.guild.id)
await ctx.send(f'Connecting to **`{channel.name}`**')
await player.connect(channel.id)
@commands.command()
async def play(self, ctx, *, query: str):
tracks = await self.bot.wavelink.get_tracks(f'ytsearch:{query}')
if not tracks:
return await ctx.send('Could not find any songs with that query.')
player = self.bot.wavelink.get_player(ctx.guild.id)
if not player.is_connected:
await ctx.invoke(self.connect_)
await ctx.send(f'Added {str(tracks[0])} to the queue.')
await player.play(tracks[0])
bot = Bot()
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
wavelink-0.4.1.tar.gz
(16.5 kB
view details)
Built Distribution
wavelink-0.4.1-py3-none-any.whl
(23.3 kB
view details)
File details
Details for the file wavelink-0.4.1.tar.gz
.
File metadata
- Download URL: wavelink-0.4.1.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 568bd26b25682b7dd3f1cb5d0851c58df8fb721c47780f2ebd22f11a3aa46b9e |
|
MD5 | 2d53b5f77754cc59ba38591110b3bf1b |
|
BLAKE2b-256 | d347ffb7ef2c305125d94a16b37d6dd2b7212626b6e2f859c61370812fa7b5d5 |
File details
Details for the file wavelink-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: wavelink-0.4.1-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecf8c6e1060e5994823931fddab7667a53b9b8af865c8eb08728d76f4afd1e2d |
|
MD5 | 81df0c35cf77ad7ab295f65a75679a8b |
|
BLAKE2b-256 | 647d49e713361438e0b61a8525a43848a30e47cb8e8e7092b54c5254edf686d8 |