{"id":33913870,"url":"https://github.com/floryn08/valheim-server-discord-bot","last_synced_at":"2026-03-13T16:02:19.038Z","repository":{"id":220993755,"uuid":"753148513","full_name":"floryn08/valheim-server-discord-bot","owner":"floryn08","description":"A Discord bot that controls your valheim deployment to start and close the server container on demand.","archived":false,"fork":false,"pushed_at":"2026-03-03T08:37:50.000Z","size":1458,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-03T11:49:16.572Z","etag":null,"topics":["discord","docker","docker-compose","helm","k8s","portainer","portainer-api","valheim"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/floryn08.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-05T15:06:35.000Z","updated_at":"2026-03-03T08:03:47.000Z","dependencies_parsed_at":"2024-03-05T22:31:52.066Z","dependency_job_id":"b641e243-097b-421e-bc4f-b6b39615afe1","html_url":"https://github.com/floryn08/valheim-server-discord-bot","commit_stats":null,"previous_names":["floryn08/valheim-server-discord-bot"],"tags_count":121,"template":false,"template_full_name":null,"purl":"pkg:github/floryn08/valheim-server-discord-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floryn08%2Fvalheim-server-discord-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floryn08%2Fvalheim-server-discord-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floryn08%2Fvalheim-server-discord-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floryn08%2Fvalheim-server-discord-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floryn08","download_url":"https://codeload.github.com/floryn08/valheim-server-discord-bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floryn08%2Fvalheim-server-discord-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30469858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T11:00:43.441Z","status":"ssl_error","status_checked_at":"2026-03-13T11:00:23.173Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord","docker","docker-compose","helm","k8s","portainer","portainer-api","valheim"],"created_at":"2025-12-12T06:05:51.771Z","updated_at":"2026-03-13T16:02:18.995Z","avatar_url":"https://github.com/floryn08.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Valheim Server Discord Bot\nA Discord bot that manages your game servers (Valheim, Terraria, etc.) using either Docker or Kubernetes.\n\nThis approach minimizes resource consumption since many game server docker images don't support auto pausing the server when there are no players on the server.\n\nThe bot registers 3 slash commands:\n- `/start \u003cserver\u003e` - Start a game server\n- `/stop \u003cserver\u003e` - Stop a game server  \n- `/status \u003cserver\u003e` - Check a game server's status\n\nEach command includes autocomplete suggestions for available servers.\n\n## Runtime Modes\n\nThe bot supports two runtime modes:\n- **kubernetes**: Manages Valheim servers running as Kubernetes deployments\n- **docker**: Manages Valheim servers running as Docker containers\n\nSet the runtime mode using the `RUNTIME_MODE` environment variable (defaults to `kubernetes`).\n\n## How to run\n\n### With Kubernetes\n\n#### Prerequisites\n- A Kubernetes cluster\n- `kubectl` configured to access your cluster\n- Helm 3 installed\n- (Optional) HashiCorp Vault for secret management\n\n#### Installation Steps\n\n1. **Invite your bot to a Discord server**\n   - Use the OAuth2 URL Generator from https://discord.com/developers/applications\n   - Select the required bot permissions\n\n2. **Install using Helm**\n\n   ```bash\n   # Navigate to the helm chart directory\n   cd deployment/helm\n\n   # Install the chart\n   helm install valheim-bot . -n game-servers --create-namespace\n   ```\n\n3. **Configure the bot**\n\n   The Helm chart supports two configuration methods:\n\n   **Option A: Using ConfigMap (for non-sensitive data)**\n   \n   Edit the ConfigMap after installation:\n   ```bash\n   kubectl edit configmap valheim-bot-discord-bot -n game-servers\n   ```\n\n   Set the following environment variables:\n   - `RUNTIME_MODE`: Set to `kubernetes` (default)\n   - `DISCORD_TOKEN`: Your Discord bot token\n   - `DISCORD_CLIENT_ID`: Your Discord application client ID\n   - `GUILD_IDS`: Comma-separated list of Discord server IDs\n   - `NAMESPACE`: The namespace where your game servers run (defaults to the chart namespace)\n   - `SERVERS`: JSON array of server configurations (see below)\n   - `JOIN_CODE_LOOP_COUNT`: (Optional) Number of retries for join code (default: 20)\n   - `JOIN_CODE_LOOP_TIMEOUT_MILLIS`: (Optional) Timeout in milliseconds (default: 5000)\n\n   **SERVERS Configuration Format:**\n   ```json\n   [\n     {\n       \"id\": \"valheim\",\n       \"resourceName\": \"valheim-deployment\",\n       \"resourceType\": \"deployment\",\n       \"containerName\": \"valheim-container\",\n       \"serverName\": \"My Valheim Server\",\n       \"startedLogPattern\": \"Session \\\"My Valheim Server\\\" with join code\",\n       \"joinCodeWordIndex\": 5\n     },\n     {\n       \"id\": \"terraria\",\n       \"resourceName\": \"terraria-statefulset\",\n       \"resourceType\": \"statefulset\",\n       \"containerName\": \"terraria-container\",\n       \"serverName\": \"My Terraria Server\",\n       \"startedLogPattern\": \"Server started\"\n     }\n   ]\n   ```\n   - `id`: Unique identifier for the server (shown in Discord autocomplete)\n   - `resourceName`: Kubernetes resource name - deployment or statefulset (required for Kubernetes mode)\n   - `resourceType`: Type of Kubernetes resource - `deployment` (default) or `statefulset` (optional)\n   - `containerName`: Docker container name (required for Docker mode)\n   - `serverName`: Display name for the server (used in messages)\n   - `startedLogPattern`: Pattern to search for in logs to detect server has started\n   - `joinCodeWordIndex`: (Optional) Word index to extract join code from matched log line\n\n   **Option B: Using HashiCorp Vault (recommended for production)**\n   \n   If you have Vault enabled (`vault.enabled: true` in values.yaml):\n   - Store secrets in Vault at path: `kv/game-servers/valheim-bot-discord-bot`\n   - The chart will automatically create a VaultStaticSecret resource\n\n4. **Customize the deployment**\n\n   Create a custom `values.yaml`:\n   ```yaml\n   namespace: game-servers\n   discordBotImage: ghcr.io/floryn08/valheim-server-discord-bot:1.2.0\n   vault:\n     enabled: false  # Set to true if using Vault\n   ```\n\n   Install with custom values:\n   ```bash\n   helm install valheim-bot . -f custom-values.yaml -n game-servers --create-namespace\n   ```\n\n5. **Verify the deployment**\n\n   ```bash\n   kubectl get pods -n game-servers\n   kubectl logs -f deployment/valheim-bot-discord-bot -n game-servers\n   ```\n\n#### Upgrading\n\nTo upgrade to a new version:\n```bash\nhelm upgrade valheim-bot . -n game-servers\n```\n\n#### Uninstalling\n\nTo remove the deployment:\n```bash\nhelm uninstall valheim-bot -n game-servers\n```\n\n### With Docker\n\n#### Prerequisites\n- Docker installed and running\n- A running game server container\n- Discord bot credentials\n\n#### Installation Steps\n\n1. **Invite your bot to a Discord server**\n   - Use the OAuth2 URL Generator from https://discord.com/developers/applications\n   - Select the required bot permissions\n\n2. **Create a `.env` file (for local development)**\n\n   ```env\n   RUNTIME_MODE=docker\n   DISCORD_TOKEN=your_discord_bot_token\n   DISCORD_CLIENT_ID=your_discord_client_id\n   GUILD_IDS=your_guild_id1,your_guild_id2\n   SERVERS='[{\"id\":\"valheim\",\"resourceName\":\"valheim-deployment\",\"containerName\":\"valheim-container\",\"serverName\":\"My Valheim Server\",\"startedLogPattern\":\"Session \\\"My Valheim Server\\\" with join code\",\"joinCodeWordIndex\":5}]'\n   # Optional\n   # DOCKER_SOCKET_PATH=/var/run/docker.sock\n   # JOIN_CODE_LOOP_COUNT=20\n   # JOIN_CODE_LOOP_TIMEOUT_MILLIS=5000\n   ```\n\n   **Environment Variables for Docker Mode:**\n   - `RUNTIME_MODE`: Set to `docker`\n   - `DISCORD_TOKEN`: Your Discord bot token\n   - `DISCORD_CLIENT_ID`: Your Discord application client ID\n   - `GUILD_IDS`: Comma-separated list of Discord server IDs\n   - `SERVERS`: JSON array of server configurations (see Kubernetes section for format)\n   - `DOCKER_SOCKET_PATH`: (Optional) Path to Docker socket (default: `/var/run/docker.sock`)\n   - `JOIN_CODE_LOOP_COUNT`: (Optional) Number of retries for join code (default: 20)\n   - `JOIN_CODE_LOOP_TIMEOUT_MILLIS`: (Optional) Timeout in milliseconds (default: 5000)\n\n3. **Run with Docker Compose**\n\n   Update the provided `deployment/docker-compose.yaml` or create your own:\n   ```yaml\n   services:\n     valheim-server-discord-bot:\n       container_name: valheim-server-discord-bot\n       image: ghcr.io/floryn08/valheim-server-discord-bot:latest\n       environment:\n         RUNTIME_MODE: docker\n         DISCORD_TOKEN: ${DISCORD_TOKEN}\n         DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID}\n         GUILD_IDS: ${GUILD_IDS}\n         SERVERS: ${SERVERS}\n         JOIN_CODE_LOOP_COUNT: ${JOIN_CODE_LOOP_COUNT:-20}\n         JOIN_CODE_LOOP_TIMEOUT_MILLIS: ${JOIN_CODE_LOOP_TIMEOUT_MILLIS:-5000}\n       volumes:\n         - /var/run/docker.sock:/var/run/docker.sock\n       restart: unless-stopped\n   ```\n\n   Run:\n   ```bash\n   docker compose -f deployment/docker-compose.yaml up -d\n   ```\n\n   **Important Notes:**\n   - The bot needs access to the Docker socket to manage containers\n   - Ensure `/var/run/docker.sock` is mounted\n   - The bot container must be on the same Docker host as the Valheim server container\n   - This works with Portainer-managed stacks as well\n\n4. **Using with Portainer**\n\n   You can deploy this stack through Portainer:\n   \n   1. In Portainer, go to **Stacks** → **Add stack**\n   2. Name your stack (e.g., `valheim-discord-bot`)\n   3. Paste the docker-compose content from `deployment/docker-compose.yaml`\n   4. Set the environment variables in Portainer's environment variables section\n   5. Deploy the stack\n   \n   The bot will manage your Valheim server container directly through the Docker API, no Portainer API configuration needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloryn08%2Fvalheim-server-discord-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloryn08%2Fvalheim-server-discord-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloryn08%2Fvalheim-server-discord-bot/lists"}