mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-14 00:14:52 +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>
31 lines
1.0 KiB
Lua
31 lines
1.0 KiB
Lua
--[[-- ExpDiscord - Commands
|
|
Commands which link and unlink the player's Discord account
|
|
]]
|
|
|
|
local Commands = require("modules/exp_commands")
|
|
|
|
local Discord = require("modules/exp_discord")
|
|
|
|
--- Links your account to the Discord account which made the code, printed once the controller answers
|
|
Commands.new("link-discord", { "exp-discord_commands.description-link" })
|
|
:optional("code", { "exp-discord_commands.arg-code" }, Commands.types.string)
|
|
:add_aliases{ "link" }
|
|
:register(function(player, code)
|
|
--- @cast code string?
|
|
if code then
|
|
Discord.link(player, code)
|
|
else
|
|
Discord.get_link(player)
|
|
end
|
|
end)
|
|
|
|
--- Removes the link to your Discord account, printed once the controller answers
|
|
Commands.new("unlink-discord", { "exp-discord_commands.description-unlink" })
|
|
:add_aliases{ "unlink" }
|
|
:register(function(player)
|
|
Discord.unlink(player)
|
|
end)
|
|
|
|
-- Access the exports from other modules using require("modules/exp_discord")
|
|
return require("modules/exp_discord/control")
|