mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-09 15:35:17 +00:00
fix(discord): accept cid in agent component interactions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user