Sonora
A full-featured, production-ready Python Lavalink client for building music-capable Discord bots. Equivalent to Riffy but in Python.
Features
- Async-first Python library compatible with Python 3.11+
- Full Lavalink protocol support (v3 & v4)
- Integrations for discord.py, py-cord, and nextcord
- Plugin system for platform adapters (YouTube, Spotify, SoundCloud)
- Voice connection management, track loading, queue management, player controls
- Node pooling & reconnection, autoplay, per-guild voice state resumption
- Clean high-level API + low-level control
- Well-documented with MkDocs
- Thoroughly tested (coverage >= 85%)
- Packaged for PyPI, CI/CD with GitHub Actions, Docker support
Installation
pip install sonora-musicpy
Quickstart
First, set up your environment variables:
cp .env.example .env
# Edit .env with your Lavalink server details and Discord token
Minimal Discord Bot Example
import discord
from discord.ext import commands
from sonora import SonoraClient
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
sonora = SonoraClient(
lavalink_nodes=[{"host": "127.0.0.1", "port": 2333, "password": "youshallnotpass"}],
node_pooling=True,
reconnect_policy={"max_retries": 5, "backoff": "exponential"}
)
@bot.event
async def on_ready():
await sonora.start()
print(f'Logged in as {bot.user}')
@bot.command()
async def join(ctx):
if ctx.author.voice:
await ctx.author.voice.channel.connect()
player = await sonora.get_player(ctx.guild.id)
await ctx.send("Joined voice channel!")
else:
await ctx.send("You need to be in a voice channel!")
@bot.command()
async def play(ctx, *, query):
player = await sonora.get_player(ctx.guild.id)
track = await player.play(query)
await ctx.send(f"Now playing: {track.title}")
bot.run(os.getenv('DISCORD_TOKEN'))
For more examples, see the examples/ directory.
Configuration
Sonora supports configuration via environment variables:
LAVALINK_HOST: Lavalink server host (default: 127.0.0.1)LAVALINK_PORT: Lavalink server port (default: 2333)LAVALINK_PASSWORD: Lavalink server passwordDISCORD_TOKEN: Your Discord bot token
See .env.example for a full list.
Documentation
Full documentation is available at https://code-xon.github.io/sonora/.
Development
Prerequisites
- Python 3.11+
- A Lavalink server (see examples/docker-compose.yml for local setup)
Setup
git clone https://github.com/code-xon/sonora.git
cd sonora
pip install -e .[dev]
pre-commit install
Testing
pytest
Building Docs
mkdocs serve
Contributing
See CONTRIBUTING.md for details.
License
MIT License - see LICENSE for details.
Contact
- Lead Developer: Ramkrishna
- Email: ramkrishna@code-xon.fun
- Issues: GitHub Issues
Metadata
Release files for sonora-musicpy 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sonora_musicpy-1.0.0.tar.gz | 23.5 kB | Without provenance | Details for sonora_musicpy-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sonora_musicpy-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for sonora_musicpy-1.0.0-py3-none-any.whl |
Total release size: 43.9 kB
Release files / sonora_musicpy-1.0.0.tar.gz
| Download URL | sonora_musicpy-1.0.0.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fdb36ecebf03d981f17e5b8e454e13195d6bcddd3c483dc7f2e54531634f29fc
|
|
BLAKE2b-256 checksum How to use checksums |
6681488304d1e218c5166c521243ac97cd77c3359692eeda10f03ce63bcb6b9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / sonora_musicpy-1.0.0-py3-none-any.whl
| Download URL | sonora_musicpy-1.0.0-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0a7c0dfab007dad346095f852cf6c123ec1a34d656743a71bdb1272f2508db3c
|
|
BLAKE2b-256 checksum How to use checksums |
8a2db86a1d768308a6c5ebd43c787e6ae1ed2ae0b78e88c471b4b0a0fc7c7d81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Security for sonora-musicpy 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.