fix: log discord deploy error details
This commit is contained in:
@@ -73,12 +73,39 @@ async function deployDiscordCommands(params: {
|
|||||||
try {
|
try {
|
||||||
await runWithRetry(() => params.client.handleDeployRequest(), "command deploy");
|
await runWithRetry(() => params.client.handleDeployRequest(), "command deploy");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
const details = formatDiscordDeployErrorDetails(err);
|
||||||
params.runtime.error?.(
|
params.runtime.error?.(
|
||||||
danger(`discord: failed to deploy native commands: ${formatErrorMessage(err)}`),
|
danger(`discord: failed to deploy native commands: ${formatErrorMessage(err)}${details}`),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatDiscordDeployErrorDetails(err: unknown): string {
|
||||||
|
if (!err || typeof err !== "object") return "";
|
||||||
|
const status = (err as { status?: unknown }).status;
|
||||||
|
const discordCode = (err as { discordCode?: unknown }).discordCode;
|
||||||
|
const rawBody = (err as { rawBody?: unknown }).rawBody;
|
||||||
|
const details: string[] = [];
|
||||||
|
if (typeof status === "number") details.push(`status=${status}`);
|
||||||
|
if (typeof discordCode === "number" || typeof discordCode === "string") {
|
||||||
|
details.push(`code=${discordCode}`);
|
||||||
|
}
|
||||||
|
if (rawBody !== undefined) {
|
||||||
|
let bodyText = "";
|
||||||
|
try {
|
||||||
|
bodyText = JSON.stringify(rawBody);
|
||||||
|
} catch {
|
||||||
|
bodyText = String(rawBody);
|
||||||
|
}
|
||||||
|
if (bodyText) {
|
||||||
|
const maxLen = 800;
|
||||||
|
const trimmed = bodyText.length > maxLen ? `${bodyText.slice(0, maxLen)}...` : bodyText;
|
||||||
|
details.push(`body=${trimmed}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return details.length > 0 ? ` (${details.join(", ")})` : "";
|
||||||
|
}
|
||||||
|
|
||||||
export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
|
export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
|
||||||
const cfg = opts.config ?? loadConfig();
|
const cfg = opts.config ?? loadConfig();
|
||||||
const account = resolveDiscordAccount({
|
const account = resolveDiscordAccount({
|
||||||
|
|||||||
Reference in New Issue
Block a user