Warring Nations

Discord setup

Docs / Discord setup. Warring Nations 5.0, pre-release.

Settings for the main Discord server, the relays, and offline mode.

Article 1Basics

  1. Install wn-discord and start once. config/wn/discord.toml is written.
  2. Put the bot token in config/wn/secrets.env as WN5_DISCORD_BOT_TOKEN. Never in chat or in a toml file.
  3. Set the application id and public key under [interactions] in discord.toml.
  4. Register your main server, then run /wnadmin discord reload after editing.

Article 2Main server file

2.1Save settings for the main Discord server as config/wn/discord-main-server.toml. Staff can still change some of them with /config.

config/wn/discord-main-server.toml (excerpt)

[server]
label = "Main WN Discord"
invite_url = ""
activity_text = "Warring Nations | {online_players} players"
presence = "online"               # online, idle, dnd, invisible

[channels]
announcements = ""
wars = ""
diplomacy = ""
nations = ""
approvals = ""     # needs approvals.enabled and the approval events
staff_alerts = ""

[account_linking]
enabled = true
require_link_for_wn_actions = true
allow_self_unlink = true

2.2Empty channel ids disable that feed. Account linking works by one-time in-game code (default) or Discord OAuth2. An optional access gate grants a role when requirements pass.

Article 3Console and connection relays

3.1Both are off by default, need a bot token and a channel id, use REST only and run on their own queues, so a slow Discord never blocks the game thread.

[console_relay]
Mirrors the log in batches. Lines at or above level are sent, stack traces are cut to stack_trace_lines. Read-only. The channel must differ from the chat bridge channel.
[player_connections]
Embeds for joins, leaves and deaths with avatar, linked Discord user and play time on leave. Fake players are skipped.
Redaction
Always on. Masks the bot token, WN5_* environment values, credential-named variables, auth headers, key=value secrets, and IP addresses while redact_ip_addresses is on.

Article 4Offline mode (Cloudflare)

4.1Optional, off by default. A Worker becomes the Discord Interactions Endpoint. Server up: it forwards unchanged. Server down: read-only commands answer from a snapshot labelled with its age, allowed state-changing requests are queued, everything else says the server is offline. Server back: it pulls the queue, verifies each request again and applies it as the original user.

  1. In discord.toml set [files] cloudflare = true and restart. config/wn/discord/cloudflare.toml is created.
  2. Set [cloudflare] enabled = true and origin_url to your public HTTPS endpoint.
  3. Store a Cloudflare API token owner-only in config/wn/cloudflare-api-token (or WN5_CLOUDFLARE_API_TOKEN).

4.2Token permissions: Workers Scripts (Edit), Workers KV Storage (Edit), Queues (Edit), Account Settings (Read). The same token file is used by the web front.

Type at least two letters. Esc closes.