A modern, multi-guild Discord bot: music playback (YouTube + Spotify via
yt-dlp), reaction-based quote saving, and persistent reminders —
all backed by PostgreSQL and shipped as an isolated two-container Docker
stack.
Siren is a ground-up rewrite of the legacy Vulkan bot: same slash-command
interaction style, none of the dead dependencies (youtube-dl, py-cord 2.4).
| Command | Description |
|---|---|
/play <query> |
Play a YouTube URL/playlist, a Spotify track/album/playlist link, or free-text search |
/search <query> |
Show the top 5 YouTube results in a dropdown and pick which to play (handy when the first hit is an official video with extra audio) |
/queue [page] |
Show the queue — paginated with ⏪ Prev Page / Next Page ⏩ buttons |
/nowplaying |
Details of the current song |
/skip / /previous |
Move forward / back through the queue |
/pause / /resume / /stop |
Playback control (/stop also clears the queue) |
/loop <off|one|all> |
Repeat the current song or the whole queue |
/shuffle / /clear / /remove <pos> / /move <from> [to] |
Queue editing |
/volume <0-200> |
Live volume control |
/history |
Recently played songs |
/leave |
Disconnect from voice |
Every Now playing message carries a control row — ⏪ previous · ⏯️ pause/resume · 🔄 replay · ⏩ skip · 📜 queue — usable by anyone listening in the voice channel (the 📜 button shows the paginated queue privately). Only the current track's message has live buttons; older ones are retired automatically.
Spotify links are resolved to metadata via the Spotify Web API, then matched
on YouTube by yt-dlp at playback time — stream URLs are always fetched
fresh, so queued tracks never expire. Siren auto-disconnects after an idle
timeout and (optionally) when everyone leaves the voice channel.
React to any message with 💬 (configurable) and Siren archives its content, author, timestamp and permalink to PostgreSQL.
| Command | Description |
|---|---|
/quote search [keyword] [user] |
Search saved quotes by text and/or author |
/quote random |
A random quote from this server's archive |
| Command | Description |
|---|---|
/remindme <duration> <message> |
e.g. /remindme 2h Check the oven — accepts 5m, 1d2h30m, 45 minutes, … |
/reminders list |
Your pending reminders (private) |
/reminders cancel <id> |
Cancel one of your reminders |
Reminders live in the database, not in memory: a tasks.loop polls for due
rows every few seconds, so restarting the container never loses a
reminder. Delivery pings you in the original channel, falling back to a DM.
| Command | Description |
|---|---|
/stocks now |
Current watchlist prices (blue chips + ETFs) as a colour-coded table |
/stocks quote <ticker> |
Full quote for one symbol — price, day/52-week range, volume, exchange, plus a 1-month price chart image |
/stocks setchannel [channel] |
Send an automated daily briefing to a channel (default 09:00 US-market time) — requires Manage Server |
/stocks disable |
Stop the daily briefing — requires Manage Server |
Briefings render as an aligned monospace table in a diff code block, so
gainers are green and losers are red. /stocks quote accepts anything
Yahoo knows: AAPL, BRK-B, indices like ^GSPC, international listings
like SAP.DE; its chart is drawn by quickchart.io from Yahoo's own
1-month close series.
Quotes come from Yahoo Finance's public chart endpoint — no API key
required (prices may be slightly delayed). The watchlist, briefing time
and timezone are configurable in .env; subscriptions are stored per guild
in PostgreSQL and survive restarts.
/chat <message> — ask a self-hosted LLM a question and get its reply, split
across follow-up messages when it runs long. Talks to an OpenAI-compatible
LiteLLM proxy (qwen3.5:9b by default); the command only appears when
LITELLM_BASE_URL and LITELLM_API_KEY are set.
/roll [max] · /coinflip · /choose <a, b, c> — carried over from the
legacy bot.
Multi-server: every guild gets its own independent music player, and all database tables are keyed by guild ID — quotes and players never leak across servers.
-
Discord Developer Portal → New Application.
-
Bot tab → copy the token (this becomes
DISCORD_TOKEN). -
Bot tab → Privileged Gateway Intents → enable Message Content Intent (required by the quote saver to read reacted-on messages).
-
Invite the bot with both scopes — replace
CLIENT_ID:https://discord.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot%20applications.commands&permissions=277062449216The permission set covers: view channels, send messages, embed links, read history, add reactions, connect and speak in voice.
Only needed if you want /play to accept open.spotify.com links. Create an
app at the Spotify Developer Dashboard
and copy the client ID/secret. No user scopes needed (metadata only).
cp .env.example .env
# edit .env: DISCORD_TOKEN, POSTGRES_PASSWORD (+ Spotify creds if wanted)docker compose up -d --build
docker compose logs -f bot # watch it come upThe bot applies its own database schema on startup (idempotent DDL), so there are no migration steps for a fresh install.
First run note: without
DEV_GUILD_ID, global slash commands can take up to an hour to appear everywhere (a Discord limitation). SetDEV_GUILD_IDto a server ID in.envfor instant sync while testing.
┌──────────────── siren-internal (internal: true) ────┐
│ bot ◄──────────────────────────────► db │
└──────────────────────────────────────────────────────┘
│
└── siren-egress (bridge) ──► internet (outbound only)
siren-internalhasinternal: true— no route to the host, the internet or any other container. PostgreSQL is reachable only by the bot.siren-egressgives only the bot outbound access (Discord gateway, YouTube, Spotify).- No ports are published by either service and Traefik is explicitly
disabled via
traefik.enable: "false"labels — there is no inbound surface at all.
PostgreSQL data lives in the named volume siren_pgdata and survives
docker compose down and image rebuilds. Back it up with:
docker compose exec db pg_dump -U siren siren > siren-backup.sqlEverything logs to stdout in a single structured format
(timestamp | LEVEL | logger | message), rotated by Docker (10 MB × 3
files per container). Tune verbosity with LOG_LEVEL in .env.
All knobs are documented inline in .env.example: idle
timeout, quote emoji, playlist cap, reminder poll interval, auto-disconnect
behaviour, and the option to pass a full DATABASE_URL instead of
individual POSTGRES_* values.
Requires Python 3.13 and ffmpeg + libopus on the host.
(3.14 is not used yet: discord.py's voice stack and asyncpg don't ship
supported wheels for it at the time of writing.)
python3.13 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
cp .env.example .env # point POSTGRES_HOST at a local postgres
python -m siren # run the bot
pytest # unit tests (queue logic, duration parser)
ruff check siren tests # lint
mypy siren # strict type-checksiren/
├── __main__.py entrypoint: env → logging → DB pool → bot
├── config.py Settings dataclass; sole reader of os.environ
├── log.py stdout logging setup
├── errors.py SirenError hierarchy → rendered as error embeds
├── bot.py SirenBot: cog loading, tree sync, global error handler
├── db/
│ ├── pool.py asyncpg pool + startup schema application (retries)
│ ├── schema.sql idempotent DDL (quotes, reminders)
│ ├── models.py Quote / Reminder row dataclasses
│ └── quotes.py, reminders.py repositories (the only SQL in the codebase)
├── music/
│ ├── track.py Track model (discord-free, unit-testable)
│ ├── queue.py TrackQueue: history + off/one/all loop modes
│ ├── ytdlp.py async yt-dlp facade (flat enqueue / fresh stream URLs)
│ ├── spotify.py Spotify link → "artist title" YouTube searches
│ └── player.py GuildPlayer: one playback task per guild
├── market.py Yahoo Finance chart client (keyless, aiohttp)
├── ui/
│ ├── player_controls.py ⏪ ⏯️ 🔄 ⏩ 📜 buttons on "Now playing"
│ ├── queue_pages.py queue embed builder + page buttons
│ └── search_select.py /search result dropdown
├── cogs/ thin slash-command layers over the above
└── utils/ duration parsing, embed factory
Design rules the codebase follows:
- Cogs are thin — validation and Discord plumbing only; behaviour lives
in
music/,db/andutils/, which are importable without a bot. - Repositories own all SQL; nothing else touches connections.
- User-facing failures are exceptions (
SirenError) caught by one global handler — no per-command try/except boilerplate, no stack traces leaking into Discord. - Stream URLs are resolved at playback time, never cached at enqueue — YouTube URLs expire.
MIT