/** Extract Discord channel ID from slash command context. */ export function parseDiscordChannelIdFromCommand(cmdCtx: Record): string | undefined { // OpenClaw passes channel context in various ways depending on the trigger const sessionKey = String(cmdCtx.sessionKey ?? ""); const m = sessionKey.match(/:discord:channel:(\d+)$/); if (m) return m[1]; // Fallback: channelId directly on context const cid = String(cmdCtx.channelId ?? ""); if (/^\d+$/.test(cid)) return cid; return undefined; }