mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 16:10:24 +00:00
Bare numeric Discord IDs (e.g. '1470130713209602050') in cron delivery.to caused 'Ambiguous Discord recipient' errors and silent delivery failures. Adds normalizeDiscordOutboundTarget() to the existing Discord normalize module (channels/plugins/normalize/discord.ts) alongside normalizeDiscordMessagingTarget. Defaults bare numeric IDs to 'channel:<id>', matching existing behavior. Both the Discord extension plugin and standalone outbound adapter use the shared helper via a one-liner resolveTarget. Fixes #14753. Related: #13927
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import type { ChannelOutboundAdapter } from "../types.js";
|
|
import { sendMessageDiscord, sendPollDiscord } from "../../../discord/send.js";
|
|
import { normalizeDiscordOutboundTarget } from "../normalize/discord.js";
|
|
|
|
export const discordOutbound: ChannelOutboundAdapter = {
|
|
deliveryMode: "direct",
|
|
chunker: null,
|
|
textChunkLimit: 2000,
|
|
pollMaxOptions: 10,
|
|
resolveTarget: ({ to }) => normalizeDiscordOutboundTarget(to),
|
|
sendText: async ({ to, text, accountId, deps, replyToId, silent }) => {
|
|
const send = deps?.sendDiscord ?? sendMessageDiscord;
|
|
const result = await send(to, text, {
|
|
verbose: false,
|
|
replyTo: replyToId ?? undefined,
|
|
accountId: accountId ?? undefined,
|
|
silent: silent ?? undefined,
|
|
});
|
|
return { channel: "discord", ...result };
|
|
},
|
|
sendMedia: async ({
|
|
to,
|
|
text,
|
|
mediaUrl,
|
|
mediaLocalRoots,
|
|
accountId,
|
|
deps,
|
|
replyToId,
|
|
silent,
|
|
}) => {
|
|
const send = deps?.sendDiscord ?? sendMessageDiscord;
|
|
const result = await send(to, text, {
|
|
verbose: false,
|
|
mediaUrl,
|
|
mediaLocalRoots,
|
|
replyTo: replyToId ?? undefined,
|
|
accountId: accountId ?? undefined,
|
|
silent: silent ?? undefined,
|
|
});
|
|
return { channel: "discord", ...result };
|
|
},
|
|
sendPoll: async ({ to, poll, accountId, silent }) =>
|
|
await sendPollDiscord(to, poll, {
|
|
accountId: accountId ?? undefined,
|
|
silent: silent ?? undefined,
|
|
}),
|
|
};
|