Details

Last Updated
last month
First Uploaded
last month
Downloads
123
Likes
1
Size
361KB
Dependency string
Caenos-CaptainHook-4.0.0
Dependants

CaptainHook - Valheim Discord Bridge Author: Caenos Version: 4.0.0

The ultimate bridge between your Valheim dedicated server and your Discord community. Real-time server stats, uptime, player locations, and more β€” all with simple HTTP and powerful bot support.

πŸš€ Features Real-time Discord Integration β€” Show online players, uptime, and more directly in your Discord

Toggleable Endpoints β€” Turn each endpoint on/off in your config (/stats, /uptime, /ping, /whereis, /version, /commands)

Live Config Reload β€” Change config without server restart using /reload

Multi-Server Ready β€” Each server runs its own mod, Discord bot merges results

Auto-Generated Configs β€” Automatically creates .cfg and needed JSON files

Zero-Dependency, No Client Mod Needed β€” Works on any dedicated server

Safe & Simple β€” Read-only HTTP API, no risk to your game server

πŸ“¦ Installation

  1. Valheim Server Setup Install BepInEx: Download from Thunderstore and install it on your Valheim server.

Install CaptainHook:

Drop CaptainHook.dll into BepInEx/plugins/

Start your server once.

This will auto-create the config: BepInEx/config/Caenos.CaptainHook.cfg

Edit Your Config: Example section:

ini Copy Edit [General] Port = 25681 BotName = CaptainHook ServerIP = 127.0.0.1

[Endpoints] EnableStats = true EnablePing = true EnableUptime = true EnableVersion = true EnableWhereIs = true EnableCommands = true (Optional) Change Endpoint Access: Toggle any command on/off from the config. Use /reload to apply changes instantlyβ€”no server restart needed.

  1. Discord Bot Setup Create Your Bot:

Go to Discord Developer Portal

Click New Application β†’ Bot β†’ Add Bot

Save the Bot Token (keep it private!)

Invite Your Bot:

Go to OAuth2 β†’ URL Generator

Select bot and applications.commands scopes, set permissions (read/send messages), copy and visit the link

Prepare the Example Python Bot:

Copy the example code below to main.py

Install required Python packages:

nginx Copy Edit pip install discord.py requests Flask Set your bot token as environment variable or replace in the script:

arduino Copy Edit export DISCORD_TOKEN=your-bot-token Run it:

css Copy Edit python main.py The bot will query your server and respond to slash commands!

πŸ€– Example Discord Bot Code python Copy Edit import discord import os import requests

HTTP_SERVER = "http://YOUR.SERVER.IP:port" # Set to your mod's HTTP config port TOKEN = os.environ.get('DISCORD_TOKEN') or "YOUR-TOKEN-HERE"

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 == "@ping": await message.channel.send(get("ping")) elif msg == "@reload": await message.channel.send(get("reload")) elif msg == "@commands": await message.channel.send( "πŸ“œ Commands: @stats, @w <name>, @ping, @uptime, @version, @reload, @commands" )

client.run(TOKEN) See package for a full-featured multi-server slash-command version.

πŸ› οΈ Configuration and Endpoints Every endpoint can be enabled/disabled in the config.

Edit config, then POST /reload to update instantly.

Supported endpoints: /stats /ping /uptime /version /whereis?name=X /commands /reload

πŸ”₯ What can you add with a Discord bot? Full Slash Command Support: List players, uptime, version, biomes, and more as Discord slash commands.

Admin Alerts: Ping admins if server goes offline.

Automated Welcome Messages: Let your bot greet new online players.

Last Seen / Activity Tracking: Extend with /seen using the bot’s database.

Server Multi-query: Merge stats from multiple servers into one reply.

Web Dashboard: Build a status website using the same API.

❓ FAQ & Troubleshooting Q: Do I have to restart my server for config changes? A: No! Use /reload to apply config instantly.

Q: Is it secure? A: The HTTP API is read-only. You should firewall it or reverse-proxy to your bot if exposed to the public.

Q: Can I use multiple bots or servers? A: Yes. Each server runs its own mod and exposes only the endpoints you want.

Q: What about /seen and other advanced features? A: The mod provides core info, but the Discord bot can add richer features like tracking last seen and command usage.

πŸ™Œ Credits Mod by Caenos

Community testers and bot contributors

πŸ“‚ Source GitHub: Coming soon!

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.