mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 06:10:22 +00:00
Address PR feedback
This commit is contained in:
committed by
clawdinator[bot]
parent
5af322f710
commit
f04e84f194
@@ -196,6 +196,12 @@ describe("handleDiscordPresenceAction", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("requires activityType when activityName is provided", async () => {
|
||||
await expect(
|
||||
handleDiscordPresenceAction("setPresence", { activityName: "My Game" }, presenceEnabled),
|
||||
).rejects.toThrow(/activityType is required/);
|
||||
});
|
||||
|
||||
it("rejects unknown presence actions", async () => {
|
||||
await expect(handleDiscordPresenceAction("unknownAction", {}, presenceEnabled)).rejects.toThrow(
|
||||
/Unknown presence action/,
|
||||
|
||||
@@ -55,7 +55,13 @@ export async function handleDiscordPresenceAction(
|
||||
const activities: Activity[] = [];
|
||||
|
||||
if (activityTypeRaw || activityName) {
|
||||
const typeNum = activityTypeRaw ? ACTIVITY_TYPE_MAP[activityTypeRaw.toLowerCase()] : 0;
|
||||
if (!activityTypeRaw) {
|
||||
throw new Error(
|
||||
"activityType is required when activityName is provided. " +
|
||||
`Valid types: ${Object.keys(ACTIVITY_TYPE_MAP).join(", ")}`,
|
||||
);
|
||||
}
|
||||
const typeNum = ACTIVITY_TYPE_MAP[activityTypeRaw.toLowerCase()];
|
||||
if (typeNum === undefined) {
|
||||
throw new Error(
|
||||
`Invalid activityType "${activityTypeRaw}". Must be one of: ${Object.keys(ACTIVITY_TYPE_MAP).join(", ")}`,
|
||||
|
||||
Reference in New Issue
Block a user