Lavalink client library for Red-DiscordBot
Project description
A Lavalink client library written for Python 3.8 using the AsyncIO framework. This library may be used for other projects as it contains no Red specific code or logic.
However, it is important to note that this library only supports projects using discord.py.
To install:
pip install red-lavalink
Usage
import lavalink
from discord.ext.commands import Bot
class MyBot(Bot):
async def setup_hook(self):
await lavalink.initialize(
self, host='localhost', password='password', port=2333
)
async def search_and_play(voice_channel, search_terms):
player = await lavalink.connect(voice_channel)
tracks = await player.search_yt(search_terms)
player.add(tracks[0])
await player.play()
Shuffling
def shuffle_queue(player_id, forced=True):
player = lavalink.get_player(player_id)
if not forced:
player.maybe_shuffle(sticky_songs=0)
"""
`player.maybe_shuffle` respects `player.shuffle`
And will only shuffle if `player.shuffle` is True.
`player.maybe_shuffle` should be called every time
you would expect the queue to be shuffled.
`sticky_songs=0` will shuffle every song in the queue.
"""
else:
player.force_shuffle(sticky_songs=3)
"""
`player.force_shuffle` does not respect `player.shuffle`
And will always shuffle the queue.
`sticky_songs=3` will shuffle every song after the first 3 songs in the queue.
"""
When shutting down, be sure to do the following:
await lavalink.close(bot)
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
Red-Lavalink-0.11.0.tar.gz
(34.0 kB
view details)
Built Distribution
File details
Details for the file Red-Lavalink-0.11.0.tar.gz
.
File metadata
- Download URL: Red-Lavalink-0.11.0.tar.gz
- Upload date:
- Size: 34.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ee2671dfc43a96b7e6be4effaa4137024de51bc5681f64a67c125bc3b7d4f99 |
|
MD5 | 86655f8758587f09324447609457e5f4 |
|
BLAKE2b-256 | 6d66b05f3661afbc22d7af10827eaf68e5da5076d73ad0c3f7028acb8bf40bfd |
File details
Details for the file Red_Lavalink-0.11.0-py3-none-any.whl
.
File metadata
- Download URL: Red_Lavalink-0.11.0-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f76329eee2ec5e4d77e0e97fe6ba76207efdcc8d963a9c39913cf91057d7920a |
|
MD5 | cb088e3a73be0c4845452648c57f46b9 |
|
BLAKE2b-256 | 2001748c284bd03e788ac2c6cf2c58f19b4d1e3ad96dae36b21e289f1bc6c5e5 |