import type { Activity, UpdatePresenceData } from "@buape/carbon/gateway"; import type { AgentToolResult } from "@mariozechner/pi-agent-core"; import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/text-runtime"; import { getGateway } from "../monitor/gateway-registry.js"; import {
type ActionGate,
jsonResult,
readStringParam,
type DiscordActionConfig,
} from "../runtime-api.js";
if (!isActionEnabled("presence", false)) { thrownew Error("Discord presence changes are disabled.");
}
const accountId = readStringParam(params, "accountId"); const gateway = getGateway(accountId); if (!gateway) { thrownew Error(
`Discord gateway not available${accountId ? ` for account "${accountId}"` : ""}. The bot may not be connected.`,
);
} if (!gateway.isConnected) { thrownew Error(
`Discord gateway is not connected${accountId ? ` for account "${accountId}"` : ""}.`,
);
}
const statusRaw = readStringParam(params, "status") ?? "online"; if (!VALID_STATUSES.has(statusRaw)) { thrownew Error(
`Invalid status "${statusRaw}". Must be one of: ${[...VALID_STATUSES].join(", ")}`,
);
} const status = statusRaw as UpdatePresenceData["status"];
// Streaming URL (Twitch/YouTube). May not render for bots but is the correct payload shape. if (typeNum === 1) { const url = readStringParam(params, "activityUrl"); if (url) {
activity.url = url;
}
}
const state = readStringParam(params, "activityState"); if (state) {
activity.state = state;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.