* Add exp_discord_sync to give linked players Discord roles
New controller plugin that maps clusterio roles to Discord roles and gives them to players linked through exp_discord_auth. The mapping is edited in a Discord Roles section on the role page, which needs the new exp_discord_sync.mapping.update permission. The guild's roles fill a dropdown, and typing a role ID still works when the bot can't list them.
Discord is reached with Node's fetch and WebSocket, no library. REST requests go one at a time and wait out 429 and exhausted rate limits. A minimal gateway connection with the Server Members intent gives roles on guild join. It identifies again instead of resuming, and every READY syncs all linked accounts, which covers startup and joins missed while disconnected. Without the intent the gateway is dropped and syncing carries on over REST.
Syncs run on link, unlink, clusterio role change, guild join, mapping change and connect. Only mapped Discord roles are ever added or removed.
exp_discord_auth may load after this plugin, so it is looked up and its hooks attached when the first sync runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Wait for exp_discord_auth with plugins.waitFor
Clusterio 2.1.2 loads plugins concurrently and lets them wait for each
other, so exp_discord_sync gets exp_discord_auth in its entrypoint and
attaches the link hooks there instead of looking it up on the first
sync. Without exp_discord_auth it logs an error and does not connect.
DiscordAuth.get() and its WeakMap had no other users and are removed,
the README shows waitFor instead. The sync tests load both plugins
through lib.PluginLoader with sync listed first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Address review of exp_discord_sync
- DiscordRest and DiscordGateway are made in fromContext and passed to
the constructor. Both read the token from config, and guildId is a
getter over config, so the plugin has no nullable bot state.
- DiscordGateway is an EventEmitter and the plugin listens with bound
methods (onGatewayReady, onGatewayDispatch, onGatewayFatalClose,
onLinkChanged).
- Private members start with an underscore.
- DiscordGateway has an explicit state (stopped, connecting,
identifying, ready, waiting) and _setState throws on a transition not
in the table. Errors while handling a gateway message are logged so
a failed assert can't take down the controller.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
- DiscordRest and DiscordGateway are made in fromContext and passed to
the constructor. Both read the token from config, and guildId is a
getter over config, so the plugin has no nullable bot state.
- DiscordGateway is an EventEmitter and the plugin listens with bound
methods (onGatewayReady, onGatewayDispatch, onGatewayFatalClose,
onLinkChanged).
- Private members start with an underscore.
- DiscordGateway has an explicit state (stopped, connecting,
identifying, ready, waiting) and _setState throws on a transition not
in the table. Errors while handling a gateway message are logged so
a failed assert can't take down the controller.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clusterio 2.1.2 loads plugins concurrently and lets them wait for each
other, so exp_discord_sync gets exp_discord_auth in its entrypoint and
attaches the link hooks there instead of looking it up on the first
sync. Without exp_discord_auth it logs an error and does not connect.
DiscordAuth.get() and its WeakMap had no other users and are removed,
the README shows waitFor instead. The sync tests load both plugins
through lib.PluginLoader with sync listed first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New controller plugin that maps clusterio roles to Discord roles and gives them to players linked through exp_discord_auth. The mapping is edited in a Discord Roles section on the role page, which needs the new exp_discord_sync.mapping.update permission. The guild's roles fill a dropdown, and typing a role ID still works when the bot can't list them.
Discord is reached with Node's fetch and WebSocket, no library. REST requests go one at a time and wait out 429 and exhausted rate limits. A minimal gateway connection with the Server Members intent gives roles on guild join. It identifies again instead of resuming, and every READY syncs all linked accounts, which covers startup and joins missed while disconnected. Without the intent the gateway is dropped and syncing carries on over REST.
Syncs run on link, unlink, clusterio role change, guild join, mapping change and connect. Only mapped Discord roles are ever added or removed.
exp_discord_auth may load after this plugin, so it is looked up and its hooks attached when the first sync runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Check the changelog section of pull request descriptions in CI
Ports the clusterio versions of the changelog scripts. pr_to_changelog.mts
gains the Contributors and Statistics blocks and a shared
checkPullRequestBody, which check_pr_changelog.mts runs on every pull
request through the new Changelog workflow. The latest release is now the
newest one targeting main. Adds the pull request template the check
expects, and node --test runs the script tests in Node.js CI.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Append the lint success line to the step summary
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Ports the clusterio versions of the changelog scripts. pr_to_changelog.mts
gains the Contributors and Statistics blocks and a shared
checkPullRequestBody, which check_pr_changelog.mts runs on every pull
request through the new Changelog workflow. The latest release is now the
newest one targeting main. Adds the pull request template the check
expects, and node --test runs the script tests in Node.js CI.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
exp_discord_auth gains a static get(controller) like exp_roles and exp_groups, getLink/getAccount/getAccounts lookups that return copies, and linked/unlinked AsyncHooks. Moving a player to another Discord account fires unlinked for the old account, then linked for the new one.
This is what exp_discord_sync needs to give linked players their Discord roles.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
clusterio #1180 made controller.hosts a HostManager. The datastore with
set and the update event now lives on controller.hosts.records.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
clusterio#1140 no longer reports plugins without a web entrypoint as
failing to load, so the empty web modules from 99d47cf1 can go. The
browser tsconfig of these plugins now checks index.ts instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clusterio#999 removed RequestError. Handlers now throw NotFoundError,
ValidationError, ConflictError or UnavailableError, and exp_auto_restart
treats any ClientError from the host as a final refusal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clusterio#1129 replaced DatastoreProvider.bootstrap with async factories
and Instance now takes its FactorioServer in the constructor, so the
instance tests pass their server stub there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
clusterio#1130 replaced webpack with Vite and the web interface rejects
webpack-built plugin bundles. Each plugin now builds with clusterioPlugin()
from @clusterio/web_ui/vite.mjs, and the webpack configs and dependencies
are gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
exp_groups and exp_roles only saved their datastores on shutdown, and
exp_scenario saved the player store but not the feature store on the
save hook. The controller runs the save hook on its autosave interval,
so a crash or kill lost every change since the controller started.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Save both datastores on the save hook so autosave covers them, the
controller also runs it at shutdown. Watch list names are case
insensitive, matching Factorio and Clusterio users. The new
exp_reports.announce_to_all_instances config, on by default, can limit
the join message to the instance the player joined. The Discord embed
lists the three newest unread reports and counts the rest in the footer,
since Discord rejects embeds with more than 25 fields. Both tables now
sort newest first by default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Players on the watch list are announced to every online admin on every
instance when they join, and the join is posted to the Discord and JSON
webhooks. The Reports page has a second table for the watch list with an
Add button and a Delete button per row.
Reports can be marked read or unread from the web interface. Each report
row also has an Add to watch list button which opens the add form filled
in with the player and reason. Setting exp_reports.watch_unread_reports
treats players with unread reports as watched.
Reports now store created_at_ms because marking them read changes
updated_at_ms. Old reports.json files migrate on load with updated_at_ms
as the creation time. The report webhook moved from the datastore update
listener to the create handler so reading a report is not posted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
utility/downloading_white was a 1.1 sprite. Neither 2.0 nor 2.1 has it,
so drawing the readme for a modded server crashed on_player_created.
utility/downloading exists in both, so no version check is needed.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>