diff --git a/config_example.json b/config_example.json index 26e358b..d0c6ef3 100644 --- a/config_example.json +++ b/config_example.json @@ -1,6 +1,8 @@ { "Comment": "Fluxer music bot configuration. Requires Node.js >= 22.13.0. Run 'node --version' to verify.", "token": "your bot token", + "instanceUrl": null, + "instanceUrl-Comment": "Optional base URL of a self-hosted Fluxer instance (e.g. 'https://chat.example.com'). Leave null or omit to connect to the official fluxer.app.", "fluxer.js": { "rest": { "Comment": "REST client options. 'timeout' is ms before a request to api.fluxer.app is aborted (default: 15000). Raise if you see DOMException AbortError in logs.", diff --git a/src/core/Bot.mjs b/src/core/Bot.mjs index 9057635..e445b0a 100644 --- a/src/core/Bot.mjs +++ b/src/core/Bot.mjs @@ -156,7 +156,7 @@ class Remix { intentionalLeaveTTL: timers.intentionalLeaveTTL ?? 10_000, }; - const client = new Client({ + const clientOptions = { waitForGuilds: true, cache: { guilds: 10_000, @@ -167,7 +167,17 @@ class Remix { }, ...config["fluxer.js"], presence: presenceContents.length === 0 ? undefined : buildRuntimePresence(presenceContents[0]), - }); + }; + + if (config.instanceUrl) { + const url = String(config.instanceUrl).trim().replace(/\/+$/, ""); + if (url) { + clientOptions.instance = { api: url }; + logger.info(`[Startup] Self-hosted instance configured: ${url}`); + } + } + + const client = new Client(clientOptions); client.setMaxListeners(50); this.client = client;