Skip to content
3 changes: 1 addition & 2 deletions scripts/generate-openclaw-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ def _placeholder(channel: str, env_key: str) -> str:
# framework allowFrom file at credentials/openclaw-weixin-{accountId}-
# allowFrom.json — not the openclaw.json accounts.<id>.allowFrom mechanism
# that telegram/discord/slack use.

if "discord" in _ch_cfg and _discord_guilds:
_ch_cfg["discord"].update(
{"groupPolicy": "allowlist", "guilds": _discord_guilds}
Expand Down Expand Up @@ -733,7 +732,7 @@ def _placeholder(channel: str, env_key: str) -> str:
for _plugin_id, _provider_keys in _bundled_provider_plugins.items():
if provider_key not in _provider_keys:
plugin_entries[_plugin_id] = {"enabled": False}

if "discord" in _ch_cfg: plugin_entries["discord"] = {"enabled": True}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
plugins = {"entries": plugin_entries}
plugin_load_paths: list[str] = []
for plugin in openclaw_plugins:
Expand Down
11 changes: 11 additions & 0 deletions test/generate-openclaw-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,17 @@ describe("generate-openclaw-config.py: config generation", () => {
expect(config.plugins.entries.xai.enabled).toBe(false);
});

it("#4246: enables the discord plugin entry when Discord channel is configured", () => {
const channels = Buffer.from(JSON.stringify(["discord"])).toString("base64");
const config = runConfigScript({ NEMOCLAW_MESSAGING_CHANNELS_B64: channels });
expect(config.plugins.entries.discord).toEqual({ enabled: true });
});

it("#4246: omits the discord plugin entry when Discord channel is not configured", () => {
const config = runConfigScript();
expect(config.plugins.entries.discord).toBeUndefined();
});

it("creates file with 0600 permissions", () => {
runConfigScript();
const configPath = path.join(tmpDir, ".openclaw", "openclaw.json");
Expand Down
Loading