Discord text boy. Keeper of Keys. Grounds of Hogwarts.
Ping him. He answers like the books — bleedin', soddin', mead on the breath.
"Eh? Speak up, yeh daft git. I haven' got all bloody day. Fang's waitin' on his supper."
Not a voice bot. Not a wizard. Just text, a pink umbrella, and rock cakes that could break a tooth.
This is the Discord Developer Portal. Don't panic. It's just paperwork.
- Open Discord Developer Portal → New Application → name it
Hagrid - Bot → Add Bot → Reset Token → copy it (that's
DISCORD_TOKEN) - Same page: turn on Message Content Intent (he can't read the common room without it)
- General Information → copy Application ID (
DISCORD_CLIENT_ID) and Public Key (DISCORD_PUBLIC_KEY)
Swap YOUR_CLIENT_ID for the Application ID. Open it while logged into Discord. Pick the server.
https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=274877975552&scope=bot%20applications.commands
Permissions: View Channels, Send Messages, Read Message History, Embed Links.
git clone https://github.com/GithubAnant/hagrid-bot.git
cd hagrid-bot
cp .env.example .envStick these in .env:
DISCORD_TOKEN=...
DISCORD_CLIENT_ID=...
DISCORD_PUBLIC_KEY=...
OPENROUTER_API_KEY=sk-or-v1-...
Then:
pnpm install
pnpm startLeave the terminal open. Hagrid shows online. In Discord: @Hagrid hello.
No OpenAI. OpenRouter free models.
- Sign up at openrouter.ai
- Copy a key from openrouter.ai/keys (
sk-or-v1-...) - Paste as
OPENROUTER_API_KEY
Default model is openrouter/free — $0, picks whatever free model is up.
New accounts: ~50 chats/day. $10 credits once → 1,000/day.
Want a specific free model:
OPENAI_MODEL=google/gemma-4-31b-it:free
Live list: openrouter.ai/models?max_price=0
No key = a handful of canned lines from the hut. Fine for a sniff. Not a conversation.
No always-on box. Discord hits the Worker. Talk with /hagrid say: ...
- Copy Public Key from Discord Developer Portal → General Information
- Deploy:
pnpm install
pnpm wrangler login
pnpm wrangler secret put DISCORD_PUBLIC_KEY
pnpm wrangler secret put OPENROUTER_API_KEY
pnpm deploy- Copy the
*.workers.devURL. Discord Developer Portal → General Information → Interactions Endpoint URL → paste that URL. Save. Discord sends a PING; Worker must return PONG (it does). - Register the slash command (needs
.envwith bot token):
pnpm register- In the server:
/hagrid say: wipe yer feet
He will look offline in the member list. That's normal. HTTP bots don't sit on the Gateway. Command still works.
Mentions (@Hagrid) still need pnpm start or Railway. Worker does not hear those.
Close the lid, Node bot vanishes. Railway if yeh want @mention chat.
- This repo: GithubAnant/hagrid-bot
- railway.app → New Project → Deploy from GitHub → this repo
- Variables:
DISCORD_TOKEN=...
DISCORD_CLIENT_ID=...
OPENROUTER_API_KEY=sk-or-v1-...
OPENAI_BASE_URL=https://openrouter.ai/api/v1
OPENAI_MODEL=openrouter/free
- Start command:
pnpm start - Logs should say
Hagrid's in.
Render: Background Worker, not Web Service. Web Service sleeps like Fang. Worker does not.
I shouldn'a said that.


