
























@@ -1,4 +1,4 @@
1-import { formatDurationSeconds, warn, type RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
1+import { warn, type RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
22import { formatErrorMessage } from "openclaw/plugin-sdk/ssrf-runtime";
33import { Client, overwriteApplicationCommands, type RequestClient } from "../internal/discord.js";
44import {
@@ -9,7 +9,6 @@ import {
99formatDiscordDeployRateLimitDetails,
1010formatDiscordDeployRateLimitWarning,
1111isDiscordDeployDailyCreateLimit,
12-resolveDiscordDeployRateLimitDetails,
1312} from "./provider.deploy-errors.js";
1413import { logDiscordStartupPhase } from "./provider.startup-log.js";
1514@@ -130,9 +129,6 @@ async function deployDiscordCommands(params: {
130129}
131130const startupStartedAt = params.startupStartedAt ?? Date.now();
132131const accountId = params.accountId ?? "default";
133-const maxAttempts = 3;
134-const maxRetryDelayMs = 15_000;
135-const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
136132const restoreDeployRestLogging = installDeployRestLogging({
137133rest: params.client.rest,
138134runtime: params.runtime,
@@ -141,46 +137,29 @@ async function deployDiscordCommands(params: {
141137shouldLogVerbose: params.shouldLogVerbose,
142138});
143139try {
144-for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
145-try {
146-await params.client.deployCommands({ mode: "reconcile" });
140+try {
141+await params.client.deployCommands({ mode: "reconcile" });
142+return;
143+} catch (err) {
144+if (isDiscordDeployDailyCreateLimit(err)) {
145+params.runtime.log?.(
146+warn(
147+`discord: native slash command deploy skipped for ${accountId}; daily application command create limit reached. Existing slash commands stay active until Discord resets the quota. Message send/receive is unaffected.`,
148+),
149+);
147150return;
148-} catch (err) {
149-if (isDiscordDeployDailyCreateLimit(err)) {
150-params.runtime.log?.(
151-warn(
152-`discord: native slash command deploy skipped for ${accountId}; daily application command create limit reached. Existing slash commands stay active until Discord resets the quota. Message send/receive is unaffected.`,
153-),
154-);
155-return;
156-}
157-const rateLimitDetails = resolveDiscordDeployRateLimitDetails(err);
158-if (!rateLimitDetails || attempt >= maxAttempts) {
159-throw err;
160-}
161-const retryAfterMs = Math.max(0, Math.ceil(rateLimitDetails.retryAfterMs ?? 0));
162-if (retryAfterMs > maxRetryDelayMs) {
163-params.runtime.log?.(
164-warn(
165-`discord: native slash command deploy skipped for ${accountId}; retry after ${formatDurationSeconds(retryAfterMs, { decimals: 1 })} exceeds startup budget. Existing slash commands stay active. Message send/receive is unaffected.`,
166-),
167-);
168-return;
169-}
170-if (params.shouldLogVerbose()) {
171-params.runtime.log?.(
172-`discord startup [${accountId}] deploy-retry ${Math.max(0, Date.now() - startupStartedAt)}ms attempt=${attempt}/${maxAttempts - 1} retryAfterMs=${retryAfterMs} scope=${rateLimitDetails.scope ?? "unknown"} code=${rateLimitDetails.discordCode ?? "unknown"}`,
173-);
174-}
175-await sleep(retryAfterMs);
176151}
152+const rateLimitWarning = formatDiscordDeployRateLimitWarning(err, accountId);
153+if (rateLimitWarning) {
154+params.runtime.log?.(warn(rateLimitWarning));
155+return;
156+}
157+throw err;
177158}
178159} catch (err) {
179-const rateLimitWarning = formatDiscordDeployRateLimitWarning(err, accountId);
180160params.runtime.log?.(
181161warn(
182-rateLimitWarning ??
183-`discord: native slash command deploy warning (not message send): ${formatDiscordDeployErrorMessage(err)}${formatDiscordDeployErrorDetails(err)}`,
162+`discord: native slash command deploy warning (not message send): ${formatDiscordDeployErrorMessage(err)}${formatDiscordDeployErrorDetails(err)}`,
184163),
185164);
186165} finally {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。