
CaptainHook
A lightweight Valheim mod that bridges server info to a Discord bot using HTTP. Shows player stats, uptime, biome location, and more.Details
CaptainHook - Valheim Discord Bridge
CaptainHook is a lightweight Valheim server mod that opens a simple HTTP interface so your Discord bot can request real-time server information like online players, uptime, biome locations, and more.
Built for ease of use, server admins can set it up in minutes and customize settings through a config file. It's ideal for anyone who wants a bot to talk to their server β no file sharing, no messy log parsing, no complicated dependencies.
π©οΈ Features
- π‘ Discord bot support for real-time Valheim stats
- π§ View online players and their biomes
- π Get server uptime and current in-game time
- π Uses HTTP (no port forwarding required if hosted locally)
- π οΈ Easily customizable via config file (IP, port, bot name)
- β Fully works on dedicated servers
π¦ Installation
π§ Server Setup (Valheim Server)
-
Install BepInEx on your Valheim dedicated server
-
Download
CaptainHook.dll
- Place it into:
BepInEx/plugins/
- Place it into:
-
Start your server once.
- This will generate the config file:
BepInEx/config/Caenos.CaptainHook.cfg
- This will generate the config file:
-
Open the config file and edit the values:
[General] ServerPort = 25662 ServerIP = 31.214.xxx.xxx # Your public IP BotDisplayName = CaptainHook
-
Restart the server β you're ready to connect a bot!
π€ Discord Bot Setup
You'll need a simple bot that can query your Valheim server using HTTP. Here's how:
- Create a bot at: https://discord.com/developers/applications
- Set the bot token as an environment variable:
DISCORD_TOKEN
- Use the Python bot template (see below)
- Invite the bot to your server
π Example Bot Code (Python)
import discord
import os
import requests
HTTP_SERVER = "http://your.ip.here:25662" # Match the config file
TOKEN = os.environ['DISCORD_TOKEN']
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
def get(endpoint):
try:
response = requests.get(f"{HTTP_SERVER}/{endpoint}", timeout=3)
return response.text
except:
return "β οΈ Could not reach server"
@client.event
async def on_ready():
print(f"Logged in as {client.user}")
@client.event
async def on_message(message):
if message.author.bot:
return
msg = message.content.lower()
if msg == "@stats":
await message.channel.send(get("stats"))
elif msg.startswith("@w "):
await message.channel.send(get(f"whereis?name={message.content[3:].strip()}"))
elif msg == "@uptime":
await message.channel.send(get("uptime"))
elif msg == "@version":
await message.channel.send(get("version"))
elif msg == "@day":
await message.channel.send(get("day"))
elif msg == "@ping":
await message.channel.send(get("ping"))
elif msg == "@commands":
await message.channel.send(
"""π Available Commands:
@stats - Online players
@w <name> - Player's biome
@ping - Server ping
@uptime - Server uptime
@version - Mod version
@day - In-game day/time
@commands - This list""")
client.run(TOKEN)
β Bot Commands
Command | Description |
---|---|
@stats |
List all online players |
@w <name> |
Show the biome a player is in |
@ping |
Checks if server is alive |
@uptime |
Server uptime (real-world time) |
@version |
Shows mod version and author |
@day |
Shows current in-game day & time |
@commands |
Lists all bot commands |
π Security Notes
- This mod opens an HTTP port β it does not use encryption.
- It is read-only and does not allow any control commands.
- If youβre using a public server, consider a reverse proxy or local firewall to restrict access.
π§ Tips
- You can host the bot anywhere β even on Replit, a Raspberry Pi, or a VPS
- If you're behind NAT or don't have port forwarding, consider using a tunnel like ngrok
- The mod works even if no players are online β great for uptime monitors!
π§ͺ Planned Features
- Discord slash command support
- Embedded visual status replies
- Admin ping alerts for server down
π Credits
Mod developed by Caenos
π Source / Repository
Coming soon on GitHub...