mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-09 00:01:17 +00:00
fix: honor discord default action runtime account
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
|
||||
import { resolveDefaultDiscordAccountId } from "../accounts.js";
|
||||
import { createDiscordRuntimeAccountContext } from "../client.js";
|
||||
import { readDiscordComponentSpec } from "../components.js";
|
||||
import {
|
||||
@@ -112,7 +113,7 @@ export async function handleDiscordMessagingAction(
|
||||
const reactionRuntimeOptions = cfg
|
||||
? createDiscordRuntimeAccountContext({
|
||||
cfg,
|
||||
accountId: accountId ?? "default",
|
||||
accountId: accountId ?? resolveDefaultDiscordAccountId(cfg),
|
||||
})
|
||||
: accountId
|
||||
? { accountId }
|
||||
|
||||
@@ -131,6 +131,36 @@ describe("handleDiscordMessagingAction", () => {
|
||||
expect(reactMessageDiscord).toHaveBeenCalledWith("C1", "M1", "✅", {});
|
||||
});
|
||||
|
||||
it("uses configured defaultAccount when cfg is provided and accountId is omitted", async () => {
|
||||
await handleDiscordMessagingAction(
|
||||
"react",
|
||||
{
|
||||
channelId: "C1",
|
||||
messageId: "M1",
|
||||
emoji: "✅",
|
||||
},
|
||||
enableAllActions,
|
||||
undefined,
|
||||
{
|
||||
channels: {
|
||||
discord: {
|
||||
defaultAccount: "work",
|
||||
accounts: {
|
||||
work: { token: "token-work" },
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
);
|
||||
|
||||
expect(reactMessageDiscord).toHaveBeenCalledWith(
|
||||
"C1",
|
||||
"M1",
|
||||
"✅",
|
||||
expect.objectContaining({ accountId: "work" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("removes reactions on empty emoji", async () => {
|
||||
await handleDiscordMessagingAction(
|
||||
"react",
|
||||
|
||||
Reference in New Issue
Block a user