Skip to content

About

Yeh're talkin' ter Hagrid — Discord text bot in book dialect. Mead, Fang, I shouldn'a said that.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Hagrid outside his hut with Fang and a pink umbrella

Yeh're talkin' ter Hagrid

Discord text boy. Keeper of Keys. Grounds of Hogwarts.
Ping him. He answers like the books — bleedin', soddin', mead on the breath.

Hagrid's Hut half-giant mead stars

Cartoon Hagrid portrait

"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.


What he is

Book Hagrid. West Country. Slightly crude. Protective like a rough uncle — not a creep.

He swears like a groundskeeper: bloody, bleedin', soddin', bugger. Talks about Fang fartin' by the fire, mead that hits like a bludger, and Dumbledore (then claps a huge hand over his mouth — I shouldn'a said that).

How to talk to him

On Cloudflare (hosted): /hagrid say: yeh alright?

On a Node process (laptop / Railway): @Hagrid yeh alright?, reply to him, or DM.

Workers can't hold Discord's WebSocket. Slash command on CF. Mentions need a always-on Node box.

Hagrid's hut, Fang by the fire, rock cakes and mead

1. Get yer keys (~4 min)

This is the Discord Developer Portal. Don't panic. It's just paperwork.

  1. Open Discord Developer Portal → New Application → name it Hagrid
  2. Bot → Add Bot → Reset Token → copy it (that's DISCORD_TOKEN)
  3. Same page: turn on Message Content Intent (he can't read the common room without it)
  4. General Information → copy Application ID (DISCORD_CLIENT_ID) and Public Key (DISCORD_PUBLIC_KEY)

2. Invite him up ter the castle (~1 min)

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.

3. Light the kettle locally (~2 min)

git clone https://github.com/GithubAnant/hagrid-bot.git
cd hagrid-bot
cp .env.example .env

Stick these in .env:

DISCORD_TOKEN=...
DISCORD_CLIENT_ID=...
DISCORD_PUBLIC_KEY=...
OPENROUTER_API_KEY=sk-or-v1-...

Then:

pnpm install
pnpm start

Leave the terminal open. Hagrid shows online. In Discord: @Hagrid hello.

Magical wireless (OpenRouter, free)

No OpenAI. OpenRouter free models.

  1. Sign up at openrouter.ai
  2. Copy a key from openrouter.ai/keys (sk-or-v1-...)
  3. 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.

4. Host on Cloudflare Workers (~6 min)

No always-on box. Discord hits the Worker. Talk with /hagrid say: ...

  1. Copy Public Key from Discord Developer Portal → General Information
  2. Deploy:
pnpm install
pnpm wrangler login
pnpm wrangler secret put DISCORD_PUBLIC_KEY
pnpm wrangler secret put OPENROUTER_API_KEY
pnpm deploy
  1. Copy the *.workers.dev URL. Discord Developer Portal → General Information → Interactions Endpoint URL → paste that URL. Save. Discord sends a PING; Worker must return PONG (it does).
  2. Register the slash command (needs .env with bot token):
pnpm register
  1. 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.

Keep him on Railway instead

Close the lid, Node bot vanishes. Railway if yeh want @mention chat.

  1. This repo: GithubAnant/hagrid-bot
  2. railway.app → New Project → Deploy from GitHub → this repo
  3. Variables:
DISCORD_TOKEN=...
DISCORD_CLIENT_ID=...
OPENROUTER_API_KEY=sk-or-v1-...
OPENAI_BASE_URL=https://openrouter.ai/api/v1
OPENAI_MODEL=openrouter/free
  1. Start command: pnpm start
  2. 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.

About

Yeh're talkin' ter Hagrid — Discord text bot in book dialect. Mead, Fang, I shouldn'a said that.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages