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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file red_lavalink-0.11.1.tar.gz.
File metadata
- Download URL: red_lavalink-0.11.1.tar.gz
- Upload date:
- Size: 34.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc6e1a2a81acbf07d3d17f547dd2e76193d29a875c9bc94c2207bc06ef7bfab3
|
|
| MD5 |
c40d5105eb98e9058ebca2a422a34807
|
|
| BLAKE2b-256 |
89bc3b62bad4188bc51eefa38810fae7e18b62dd24a0d69bb82f9d1f67e7ace7
|
Provenance
The following attestation bundles were made for red_lavalink-0.11.1.tar.gz:
Publisher:
publish_release.yaml on Cog-Creators/Red-Lavalink
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
red_lavalink-0.11.1.tar.gz -
Subject digest:
dc6e1a2a81acbf07d3d17f547dd2e76193d29a875c9bc94c2207bc06ef7bfab3 - Sigstore transparency entry: 1020629046
- Sigstore integration time:
-
Permalink:
Cog-Creators/Red-Lavalink@3c512f0bf02433afc45b222e294997216f7a8842 -
Branch / Tag:
refs/tags/0.11.1 - Owner: https://github.com/Cog-Creators
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_release.yaml@3c512f0bf02433afc45b222e294997216f7a8842 -
Trigger Event:
release
-
Statement type:
File details
Details for the file red_lavalink-0.11.1-py3-none-any.whl.
File metadata
- Download URL: red_lavalink-0.11.1-py3-none-any.whl
- Upload date:
- Size: 36.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e4a19b1b766971599df3736cf1777835afd74bb223fe0917e5362891779c575
|
|
| MD5 |
13c49f80aeb33a4adf918138afa1e878
|
|
| BLAKE2b-256 |
92fb04531929a34722b54a30555c2ed615c30d93fb70da31b708b0780a018ca0
|
Provenance
The following attestation bundles were made for red_lavalink-0.11.1-py3-none-any.whl:
Publisher:
publish_release.yaml on Cog-Creators/Red-Lavalink
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
red_lavalink-0.11.1-py3-none-any.whl -
Subject digest:
2e4a19b1b766971599df3736cf1777835afd74bb223fe0917e5362891779c575 - Sigstore transparency entry: 1020629087
- Sigstore integration time:
-
Permalink:
Cog-Creators/Red-Lavalink@3c512f0bf02433afc45b222e294997216f7a8842 -
Branch / Tag:
refs/tags/0.11.1 - Owner: https://github.com/Cog-Creators
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_release.yaml@3c512f0bf02433afc45b222e294997216f7a8842 -
Trigger Event:
release
-
Statement type: