● archived2021–2023

Valheim Discord Bot

A Discord bot that let a friend group start, stop, and monitor a self-hosted Valheim server on GCP — real-time notifications for joins, deaths, and invasions without anyone needing to SSH in.

TypeScriptDiscord.jsGCPPub/SubFirestoreDocker

highlights

  • Log-driven event pipeline through GCP Logging → Pub/Sub → Discord
  • Player stats (deaths, joins, playtime) persisted in Firestore
  • Migrated from JS + pm2 on Windows to a fully Dockerized TypeScript bot
  • Invasion notifications with creature type identification

Overview

Built to give a friend group control over a self-hosted Valheim server without anyone needing to SSH in. The bot handled server start/stop via the Compute Engine API, forwarded game events to Discord in real time, and tracked player stats in Firestore. Shut down in early 2023 after the group finished the game.

Valheim Discord Bot Evolution

  1. 2021-02Initial commit as game-server-notifications — JS + pm2 on Windows
  2. 2021-03v1.2 — invasion notifications · renamed · v2.0 — stats and playtime tracking
  3. 2022-09Discord privileged intents broke — fixed + package updates
  4. 2022-12v3.0 — TypeScript migration · bot Dockerized
  5. 2023-03GCE instance deleted · game finished

Architecture

The Valheim server exposes no API — everything was driven by log parsing:

Valheim Server (Docker on GCE)
  → logs via gcplogs driver
  → Google Cloud Logging (filtered to ~8 event patterns)
  → Pub/Sub topic: ValheimServerLog
  → Discord bot subscriber
  → Discord channel notifications + Firestore state

Log filter patterns covered player joins, deaths, world saves, server start/stop, version checks, invasions, and update events.

learnings

  • The Discord API changed privileged intents silently — the bot stopped working months before anyone noticed
  • Idle GCE boot disks still cost money; always filter billing by SKU to catch surprise charges
  • Log parsing is a surprisingly effective substitute for a proper webhook API
(END)q back