Article 1Basics
- Install
wn-discordand start once.config/wn/discord.tomlis written. - Put the bot token in
config/wn/secrets.envasWN5_DISCORD_BOT_TOKEN. Never in chat or in a toml file. - Set the application id and public key under
[interactions]indiscord.toml. - Register your main server, then run
/wnadmin discord reloadafter 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 = true2.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
levelare sent, stack traces are cut tostack_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=valuesecrets, and IP addresses whileredact_ip_addressesis 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.
- In
discord.tomlset[files] cloudflare = trueand restart.config/wn/discord/cloudflare.tomlis created. - Set
[cloudflare] enabled = trueandorigin_urlto your public HTTPS endpoint. - Store a Cloudflare API token owner-only in
config/wn/cloudflare-api-token(orWN5_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.