pylolka
Fork of pycord (MIT License, © 2015-2021 Rapptz, © 2021-present Pycord Development).
pylolka (imported as import lolka) is a Python wrapper for the lolka bot API, built on py-cord 2.8.1. It targets lolka by default — no manual REST/Gateway overrides needed — decodes lolka snowflakes, and resolves lolka CDN asset URLs. Slash commands, cogs, UI components, lolka.ext.commands, lolka.ext.bridge, lolka.ext.pages and lolka.ext.tasks keep the py-cord API. See LICENSE for licensing (the original MIT copyrights are retained).
Installing
Python 3.10 or higher is required
# Linux/macOS
python3 -m pip install -U pylolka
# Windows
py -3 -m pip install -U pylolka
Quick Example
import lolka
bot = lolka.Bot()
@bot.slash_command()
async def ping(ctx):
await ctx.respond("pong")
bot.run("token")
Bot Example
import lolka
from lolka.ext import commands
intents = lolka.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix=">", intents=intents)
@bot.command()
async def ping(ctx):
await ctx.send("pong")
bot.run("token")
Configuration
The defaults point to lolka. They are read from the environment when lolka is imported, so set them before import lolka:
LOLKA_API_BASE — REST API base URL (default https://lolka.app/api/bot)
LOLKA_GATEWAY — Gateway URL (default wss://lolka.app/ws/bot)
LOLKA_CDN — CDN base URL for asset links (default https://cdn.lolka.app)
Voice
Voice works over WebRTC (lolka’s voice stack), not Discord’s UDP/PyNaCl/DAVE transport. The required dependencies ship with the base install — nothing extra to add.
The API stays py-cord-compatible — await channel.connect() returns a VoiceClient that speaks lolka’s WebRTC voice under the hood:
vc = await channel.connect()
vc.play(lolka.FFmpegPCMAudio("song.mp3"))
# receive other participants' audio (optional):
async def on_track(track, user_id, producer_id):
... # track is an aiortc MediaStreamTrack
vc.on_receive_track = on_track
...
await vc.disconnect()
The track passed to on_receive_track only delivers frames from the moment it was handed over and keeps just the latest one, so read it (await track.recv() in a loop until MediaStreamError) or call track.stop() if you do not need it. Only audio producers are consumed (video is ignored).
after callbacks of vc.play() run in a helper thread, like in pycord, so they may block or call vc.play() again; use asyncio.run_coroutine_threadsafe(coro, vc.loop) to run a coroutine from them. Unlike in pycord, after is called after source.cleanup() (not before); if the source’s read() hangs, after is called after 2 seconds, before cleanup(), which runs once read() returns. vc.stop_recording() finalizes the sink asynchronously: the recording callback arrives after the call returns. A new start_recording right after stop_recording() works when called from the event loop; from another thread the finalization is scheduled through the loop, and until it runs start_recording raises ClientException.
If the voice connection is lost (the voice server restarted, the network dropped), the client disconnects and leaves the channel; reconnect=True is accepted for compatibility but reconnecting is up to the bot.
Recording works through the usual sinks. Every participant’s incoming audio is written to the sink as 48 kHz 16-bit stereo PCM under the participant’s user ID. Only audio received after start_recording() is written, and no silence is inserted between talking: the tracks of different users are not time-aligned. Both pycord callback contracts are supported. With extra arguments (or an async def callback) it is the pycord 2.0 - 2.6 style, callback(sink, *args):
async def finished(sink, channel):
files = [lolka.File(audio.file, f"{user_id}.wav") for user_id, audio in sink.audio_data.items()]
await channel.send("Done recording!", files=files)
vc = await channel.connect()
vc.start_recording(lolka.sinks.WaveSink(), finished, text_channel)
...
vc.stop_recording()
Without extra arguments and with a regular function it is the pycord 2.7+ style, callback(error), where error is the first exception raised while recording or finishing the sink (or None); keep a reference to the sink yourself:
sink = lolka.sinks.WaveSink()
def finished(error):
if error is None:
print(len(sink.audio_data), "users recorded")
vc.start_recording(sink, finished)
...
vc.stop_recording()
The sink is finalized (e.g. mp3/ogg conversion through ffmpeg) in a worker thread, so the bot stays responsive.
Recording and on_receive_track can be used together. Raw UDP helpers (send_audio_packet) are not available over WebRTC — use vc.play() with an audio source.
Migrating from pycord
Already have a pycord bot? You don’t have to rewrite it — just alias the import:
import lolka as discord
from lolka.ext import commands
# everything below is unmodified pycord bot code
bot = commands.Bot(command_prefix=">", intents=discord.Intents.default())
@bot.slash_command()
async def ping(ctx):
await ctx.respond("pong")
bot.run("token")
import lolka as discord covers every discord.Whatever attribute access in your existing code (discord.Bot, discord.Intents, discord.Embed, discord.option, discord.sinks, discord.ui and so on). The only lines that actually need editing are explicit submodule imports, since Python resolves those by real module path rather than by the alias:
import discord → import lolka as discord
from discord import X → from lolka import X
from discord import option → from lolka import option
from discord.ext import commands → from lolka.ext import commands (same for bridge, pages, tasks)
from discord.commands import ... → from lolka.commands import ...
from discord.ui import ... → from lolka.ui import ...
in general, from discord.<sub> import … → from lolka.<sub> import … for any submodule (sinks, voice, commands, ext.*, ui, …)
That’s it — the rest of your bot’s code stays exactly as it is.
Metadata
Release files for pylolka 0.1.2
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 |
|---|---|---|---|---|
| pylolka-0.1.2.tar.gz | 1.1 MB | With provenance | Details for pylolka-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylolka-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for pylolka-0.1.2-py3-none-any.whl |
Total release size: 2.4 MB
Release files / pylolka-0.1.2.tar.gz
| Download URL | pylolka-0.1.2.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e73f498a9cb8a62850ac187fb2bd4623a1c4123d59cc60d66ac16cd79329c69c
|
|
BLAKE2b-256 checksum How to use checksums |
c960d9701f5601f8e582b6c5c1feef08bd1e33723a838d210f4854031fd1c137
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logRelease files / pylolka-0.1.2-py3-none-any.whl
| Download URL | pylolka-0.1.2-py3-none-any.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9530f6cfb4888c654b7e5c7b9f4ffe99e0add771d779702cdb6f357ed3e24665
|
|
BLAKE2b-256 checksum How to use checksums |
2c33a8608df9527b1a1efcc8b7ff16c4b34fad6aa459e03f9bb0fb80206d3d10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logSecurity for pylolka 0.1.2
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pylolka-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logA 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.