mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:41:25 +00:00
chore: Enable "curly" rule to avoid single-statement if confusion/errors.
This commit is contained in:
@@ -9,9 +9,13 @@ export type DiscordTokenResolution = {
|
||||
};
|
||||
|
||||
export function normalizeDiscordToken(raw?: string | null): string | undefined {
|
||||
if (!raw) return undefined;
|
||||
if (!raw) {
|
||||
return undefined;
|
||||
}
|
||||
const trimmed = raw.trim();
|
||||
if (!trimmed) return undefined;
|
||||
if (!trimmed) {
|
||||
return undefined;
|
||||
}
|
||||
return trimmed.replace(/^Bot\s+/i, "");
|
||||
}
|
||||
|
||||
@@ -26,16 +30,22 @@ export function resolveDiscordToken(
|
||||
? discordCfg?.accounts?.[accountId]
|
||||
: discordCfg?.accounts?.[DEFAULT_ACCOUNT_ID];
|
||||
const accountToken = normalizeDiscordToken(accountCfg?.token ?? undefined);
|
||||
if (accountToken) return { token: accountToken, source: "config" };
|
||||
if (accountToken) {
|
||||
return { token: accountToken, source: "config" };
|
||||
}
|
||||
|
||||
const allowEnv = accountId === DEFAULT_ACCOUNT_ID;
|
||||
const configToken = allowEnv ? normalizeDiscordToken(discordCfg?.token ?? undefined) : undefined;
|
||||
if (configToken) return { token: configToken, source: "config" };
|
||||
if (configToken) {
|
||||
return { token: configToken, source: "config" };
|
||||
}
|
||||
|
||||
const envToken = allowEnv
|
||||
? normalizeDiscordToken(opts.envToken ?? process.env.DISCORD_BOT_TOKEN)
|
||||
: undefined;
|
||||
if (envToken) return { token: envToken, source: "env" };
|
||||
if (envToken) {
|
||||
return { token: envToken, source: "env" };
|
||||
}
|
||||
|
||||
return { token: "", source: "none" };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user