Skip to content

Commit c7554d3

Browse files
committed
fix: honor discord default action runtime account
1 parent 0bbacca commit c7554d3

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

extensions/discord/src/actions/runtime.messaging.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
2+
import { resolveDefaultDiscordAccountId } from "../accounts.js";
23
import { createDiscordRuntimeAccountContext } from "../client.js";
34
import { readDiscordComponentSpec } from "../components.js";
45
import {
@@ -112,7 +113,7 @@ export async function handleDiscordMessagingAction(
112113
const reactionRuntimeOptions = cfg
113114
? createDiscordRuntimeAccountContext({
114115
cfg,
115-
accountId: accountId ?? "default",
116+
accountId: accountId ?? resolveDefaultDiscordAccountId(cfg),
116117
})
117118
: accountId
118119
? { accountId }

extensions/discord/src/actions/runtime.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,36 @@ describe("handleDiscordMessagingAction", () => {
131131
expect(reactMessageDiscord).toHaveBeenCalledWith("C1", "M1", "✅", {});
132132
});
133133

134+
it("uses configured defaultAccount when cfg is provided and accountId is omitted", async () => {
135+
await handleDiscordMessagingAction(
136+
"react",
137+
{
138+
channelId: "C1",
139+
messageId: "M1",
140+
emoji: "✅",
141+
},
142+
enableAllActions,
143+
undefined,
144+
{
145+
channels: {
146+
discord: {
147+
defaultAccount: "work",
148+
accounts: {
149+
work: { token: "token-work" },
150+
},
151+
},
152+
},
153+
} as OpenClawConfig,
154+
);
155+
156+
expect(reactMessageDiscord).toHaveBeenCalledWith(
157+
"C1",
158+
"M1",
159+
"✅",
160+
expect.objectContaining({ accountId: "work" }),
161+
);
162+
});
163+
134164
it("removes reactions on empty emoji", async () => {
135165
await handleDiscordMessagingAction(
136166
"react",

0 commit comments

Comments
 (0)