mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
refactor(discord): dedupe onboarding config patching
This commit is contained in:
@@ -55,10 +55,10 @@ async function noteDiscordTokenHelp(prompter: WizardPrompter): Promise<void> {
|
||||
);
|
||||
}
|
||||
|
||||
function setDiscordGroupPolicy(
|
||||
function patchDiscordConfigForAccount(
|
||||
cfg: OpenClawConfig,
|
||||
accountId: string,
|
||||
groupPolicy: "open" | "allowlist" | "disabled",
|
||||
patch: Record<string, unknown>,
|
||||
): OpenClawConfig {
|
||||
if (accountId === DEFAULT_ACCOUNT_ID) {
|
||||
return {
|
||||
@@ -68,7 +68,7 @@ function setDiscordGroupPolicy(
|
||||
discord: {
|
||||
...cfg.channels?.discord,
|
||||
enabled: true,
|
||||
groupPolicy,
|
||||
...patch,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -85,7 +85,7 @@ function setDiscordGroupPolicy(
|
||||
[accountId]: {
|
||||
...cfg.channels?.discord?.accounts?.[accountId],
|
||||
enabled: cfg.channels?.discord?.accounts?.[accountId]?.enabled ?? true,
|
||||
groupPolicy,
|
||||
...patch,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -93,6 +93,14 @@ function setDiscordGroupPolicy(
|
||||
};
|
||||
}
|
||||
|
||||
function setDiscordGroupPolicy(
|
||||
cfg: OpenClawConfig,
|
||||
accountId: string,
|
||||
groupPolicy: "open" | "allowlist" | "disabled",
|
||||
): OpenClawConfig {
|
||||
return patchDiscordConfigForAccount(cfg, accountId, { groupPolicy });
|
||||
}
|
||||
|
||||
function setDiscordGuildChannelAllowlist(
|
||||
cfg: OpenClawConfig,
|
||||
accountId: string,
|
||||
@@ -117,37 +125,7 @@ function setDiscordGuildChannelAllowlist(
|
||||
guilds[guildKey] = existing;
|
||||
}
|
||||
}
|
||||
if (accountId === DEFAULT_ACCOUNT_ID) {
|
||||
return {
|
||||
...cfg,
|
||||
channels: {
|
||||
...cfg.channels,
|
||||
discord: {
|
||||
...cfg.channels?.discord,
|
||||
enabled: true,
|
||||
guilds,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
...cfg,
|
||||
channels: {
|
||||
...cfg.channels,
|
||||
discord: {
|
||||
...cfg.channels?.discord,
|
||||
enabled: true,
|
||||
accounts: {
|
||||
...cfg.channels?.discord?.accounts,
|
||||
[accountId]: {
|
||||
...cfg.channels?.discord?.accounts?.[accountId],
|
||||
enabled: cfg.channels?.discord?.accounts?.[accountId]?.enabled ?? true,
|
||||
guilds,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
return patchDiscordConfigForAccount(cfg, accountId, { guilds });
|
||||
}
|
||||
|
||||
function setDiscordAllowFrom(cfg: OpenClawConfig, allowFrom: string[]): OpenClawConfig {
|
||||
|
||||
Reference in New Issue
Block a user