mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-20 23:33:12 +09:00
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>
74 lines
1.9 KiB
TypeScript
74 lines
1.9 KiB
TypeScript
import * as lib from "@clusterio/lib";
|
|
import * as messages from "./messages.js";
|
|
|
|
declare module "@clusterio/lib" {
|
|
export interface ControllerConfigFields {
|
|
"exp_discord.client_id": string | null;
|
|
"exp_discord.client_secret": string | null;
|
|
"exp_discord.max_accounts": number;
|
|
}
|
|
export interface Permissions {
|
|
"exp_discord.link.get": never;
|
|
"exp_discord.link.delete": never;
|
|
}
|
|
}
|
|
|
|
export const plugin: lib.PluginDeclaration = {
|
|
name: "exp_discord",
|
|
title: "ExpGaming - Discord",
|
|
description: "Clusterio plugin linking Factorio accounts to Discord accounts and logging in to the web interface with Discord",
|
|
|
|
features: [
|
|
"SavePatching",
|
|
"ScriptCommands",
|
|
],
|
|
|
|
messages: [
|
|
messages.DiscordLinkRequest,
|
|
messages.DiscordUnlinkRequest,
|
|
messages.DiscordLinkGetRequest,
|
|
],
|
|
|
|
permissions: [
|
|
{
|
|
name: "exp_discord.link.get",
|
|
title: "Get Discord Links",
|
|
description: "See which Discord account any user is linked to, users can always see their own.",
|
|
grantByDefault: false,
|
|
},
|
|
{
|
|
name: "exp_discord.link.delete",
|
|
title: "Remove Discord Links",
|
|
description: "Unlink any user from their Discord account, users can always unlink themselves.",
|
|
grantByDefault: false,
|
|
},
|
|
],
|
|
|
|
instanceEntrypoint: "./dist/node/instance.js",
|
|
|
|
controllerEntrypoint: "./dist/node/controller.js",
|
|
controllerConfigFields: {
|
|
"exp_discord.client_id": {
|
|
title: "Client ID",
|
|
description: "Application ID of the Discord application used for logging in.",
|
|
type: "string",
|
|
optional: true,
|
|
},
|
|
"exp_discord.client_secret": {
|
|
title: "Client Secret",
|
|
description: "OAuth2 client secret of the Discord application used for logging in.",
|
|
type: "string",
|
|
credential: ["controller"],
|
|
optional: true,
|
|
},
|
|
"exp_discord.max_accounts": {
|
|
title: "Max Accounts",
|
|
description: "Number of Factorio accounts which can be linked to one Discord account.",
|
|
type: "number",
|
|
initialValue: 3,
|
|
},
|
|
},
|
|
|
|
webEntrypoint: "./web",
|
|
};
|