mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-17 14:25:27 +09:00
* Add exp_discord plugin for Discord login and account linking Players log in to the web interface with Discord through OAuth2 with the identify scope, so no bot token is needed. After logging in they get a code from the login page and type /link-discord <code> in game to link that Factorio account. One Discord account can hold up to exp_discord.max_accounts Factorio accounts (default 3), and linking a name moves it off any other Discord account. Sessions and link codes live in memory on the controller plugin, the links are stored in database/exp_discord/accounts.json. The user page shows the linked Discord account and lets the user, or anyone with exp_discord.link.delete, unlink it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Link Discord from the user page and document the setup The user page gets a Link Discord button. It asks the controller for a one-time ticket bound to the logged in user, then goes through the authorize route with it. The callback links the Discord account to that user directly, without the in-game code, and goes back to the user page. The link flow always shows the Discord consent screen. The README covers registering the redirect URL and the config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: bbassie <17990055+bbassie@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
2.4 KiB
Markdown
44 lines
2.4 KiB
Markdown
# ExpGaming - Discord
|
|
|
|
Lets players log in to the web interface with Discord, and links their Factorio accounts to a Discord account. It only uses the OAuth2 `identify` scope, so no bot is needed.
|
|
|
|
## Setup
|
|
|
|
1. Create an application in the [Discord developer portal](https://discord.com/developers/applications).
|
|
2. Under OAuth2, copy the Client ID and reset the Client Secret to get one.
|
|
3. Under OAuth2 → Redirects, add `<controller.public_url>api/exp_discord/callback`. For a controller with `controller.public_url` set to `https://example.com/cluster/` that is `https://example.com/cluster/api/exp_discord/callback`. It must match exactly, including the trailing path and http or https.
|
|
4. Set the config on the controller:
|
|
|
|
```
|
|
npx clusterioctl controller config set controller.public_url https://example.com/cluster/
|
|
npx clusterioctl controller config set exp_discord.client_id <client id>
|
|
npx clusterioctl controller config set exp_discord.client_secret <client secret>
|
|
```
|
|
|
|
`controller.public_url` has to be set, because the redirect URL is built from it and Discord rejects any URL that isn't registered.
|
|
|
|
## Config
|
|
|
|
All fields are on the controller.
|
|
|
|
| Field | Default | Description |
|
|
|---|---|---|
|
|
| `exp_discord.client_id` | | Application ID of the Discord application. |
|
|
| `exp_discord.client_secret` | | OAuth2 client secret of the Discord application. Only readable on the controller. |
|
|
| `exp_discord.max_accounts` | 3 | How many Factorio accounts one Discord account can link. |
|
|
|
|
## Linking
|
|
|
|
There are two ways to link a Factorio account:
|
|
|
|
- On the user page, a logged in user clicks Link Discord and approves it on Discord.
|
|
- On the login page, a player logs in with Discord and gets a code, then types `/link-discord CODE` on any server. This is how a player who can't log in to the web interface yet links their account.
|
|
|
|
Linking a Factorio account that is already linked to another Discord account moves it. `/link-discord` without a code shows the current link, and `/unlink-discord` removes it. The user page has an Unlink button too.
|
|
|
|
Users can always see and remove their own link. The `exp_discord.link.get` and `exp_discord.link.delete` permissions allow it for other users.
|
|
|
|
Once linked, the Discord tab on the login page has a "Log in as" button for each linked account. Banned users can't log in this way.
|
|
|
|
Links are stored in `database/exp_discord/accounts.json` on the controller.
|