A tiny discord bot written in C. say "king" in a channel and it reacts with 👑.
Built with Cosmopolitan Libc, so make spits out a single binary that runs on Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD. No Docker, no runtime deps.
git clone --recursive https://github.com/SteveParson/king.git
makeexport DISCORD_TOKEN='<your_token_here>'
./kingOr copy .env.sample to .env, fill in your token, and source it before running.
You need Message Content Intent enabled in the Discord Developer Portal.
| Variable | Default | What it does |
|---|---|---|
DISCORD_TOKEN |
(required) | Bot token (no Bot prefix) |
DISCORD_REPLY |
(disabled) | Reply text, omit to disable |
DISCORD_REACTION |
👑 |
Reaction emoji |
LOG_LEVEL |
info |
error, info, or debug |
A pre-built image is published to the GitHub Container Registry:
docker run -e DISCORD_TOKEN='<your_token_here>' ghcr.io/steveparson/king:latestOr using a .env file:
cp .env.sample .env
# edit .env with your token
docker run --env-file .env ghcr.io/steveparson/king:latestRun make test to run the tests.
~1000 lines of C, Connects to the Discord Gateway over WebSocket/TLS (mbedtls, vendored), listens for messages, checks for the word "king" (case-insensitive, whole-word match), and fires off a REST reply + reaction. Heartbeats, reconnects, the usual Gateway lifecycle stuff.
Things we cook in this repo might not be very baked, but from our bit of testing, it 'works'.