fix(discord): accept cid in agent component interactions

This commit is contained in:
李肖然
2026-02-28 01:47:16 +08:00
committed by Peter Steinberger
parent 25b731c34a
commit 9aba8422ca

View File

@@ -414,12 +414,22 @@ function parseAgentComponentData(data: ComponentData): {
if (!data || typeof data !== "object") {
return null;
}
// Carbon parses "key:componentId=xxx" into { componentId: "xxx" }
// Components v2 / other builders may use { cid: "xxx" } (e.g. occomp:cid=xxx).
const raw =
("cid" in data
? (data as Record<string, unknown>).cid
: (data as Record<string, unknown>).componentId) ??
(data as Record<string, unknown>).componentId;
const componentId =
typeof data.componentId === "string"
? decodeURIComponent(data.componentId)
: typeof data.componentId === "number"
? String(data.componentId)
typeof raw === "string"
? decodeURIComponent(raw)
: typeof raw === "number"
? String(raw)
: null;
if (!componentId) {
return null;
}