16ec4537ca504197cf633b391473f38fcd8e480a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
discord-bot
A Discord music bot (discord.js v14 + @discordjs/voice, with DAVE E2EE voice support). It plays audio from YouTube and anything else yt-dlp supports, and keeps a local Opus cache so repeated songs start right away. The bot replies in Polish.
This is the version running on the home server (laptopdell) as discordbot.service.
Commands (prefix !)
| Command | What it does |
|---|---|
!play <url or search> |
Queue a track |
!fplay <url or search> |
Same, but skips the cache and downloads it again |
!skip / !queue / !stop / !leave |
Skip, show the queue, stop and clear it, disconnect |
!drop start @a @b @c @d |
Mini-game: rolls a "token" (1:137 500) and a "gold outfit" (1:1 562 500) for each player every second. Also !drop stop and !drop stats |
!help |
List commands |
How it works
- yt-dlp downloads audio with
--cookies-from-browser firefoxandplayer_client=default,web_embedded(works around yt-dlp#17389). ffprobe reads the duration. - Tracks longer than 10 s are saved as
cache/<sha>.opus.cache/metadata.jsonmaps URLs to files. Files under 4 KB are treated as broken and downloaded again. - Volume is fixed at 0.3 (
VOLUMEinindex.js).
Setup
npm install
echo 'DISCORD_TOKEN=...' > .env
node index.js
Needs yt-dlp, ffmpeg, Node 18+, and a Firefox profile logged in to YouTube on the same machine for cookies.
systemd
discordbot.service runs it as user kq from /home/kq/discordbot:
sudo cp discordbot.service /etc/systemd/system/
sudo systemctl enable --now discordbot
Languages
JavaScript
100%