Files
bbassieandClaude Opus 5.5 1c713ba0aa Address review of the Discord plugin
The plugin is now exp_discord_auth, so later Discord plugins can sit
next to it. Config keys, permissions, routes and the Lua module moved
with it, and the Discord redirect is now api/exp_discord_auth/callback.

The controller registers its handlers and routes in the constructor and
uses the express types, the instance plugin is a closure, and the Lua
commands file returns its commands. The get and unlink responses carry
the controller url so the in game messages can name the website.

The login form asks the new status route whether Discord is configured
and shows the error straight away instead of a button that fails. The
button is full width like the link button, and a "Not you?" link next
to the Discord name replaces the separate switch account button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 13:38:20 +00:00

75 lines
2.0 KiB
TypeScript

import * as lib from "@clusterio/lib";
import * as messages from "./messages.js";
declare module "@clusterio/lib" {
export interface ControllerConfigFields {
"exp_discord_auth.client_id": string | null;
"exp_discord_auth.client_secret": string | null;
"exp_discord_auth.max_accounts": number;
}
export interface Permissions {
"exp_discord_auth.link.get": never;
"exp_discord_auth.link.delete": never;
}
}
export const plugin: lib.PluginDeclaration = {
name: "exp_discord_auth",
title: "ExpGaming - Discord Auth",
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,
messages.DiscordLinkStartRequest,
],
permissions: [
{
name: "exp_discord_auth.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_auth.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_auth.client_id": {
title: "Client ID",
description: "Application ID of the Discord application used for logging in.",
type: "string",
optional: true,
},
"exp_discord_auth.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_auth.max_accounts": {
title: "Max Accounts",
description: "Number of Factorio accounts which can be linked to one Discord account.",
type: "number",
initialValue: 3,
},
},
webEntrypoint: "./web",
};