mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 07:57:28 +00:00
fix(discord): improve outbound send consistency
This commit is contained in:
@@ -62,6 +62,31 @@ type DiscordChannelMessageResult = {
|
|||||||
channel_id?: string | null;
|
channel_id?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function sendDiscordThreadTextChunks(params: {
|
||||||
|
rest: RequestClient;
|
||||||
|
threadId: string;
|
||||||
|
chunks: readonly string[];
|
||||||
|
request: DiscordClientRequest;
|
||||||
|
maxLinesPerMessage?: number;
|
||||||
|
chunkMode: ReturnType<typeof resolveChunkMode>;
|
||||||
|
silent?: boolean;
|
||||||
|
}): Promise<void> {
|
||||||
|
for (const chunk of params.chunks) {
|
||||||
|
await sendDiscordText(
|
||||||
|
params.rest,
|
||||||
|
params.threadId,
|
||||||
|
chunk,
|
||||||
|
undefined,
|
||||||
|
params.request,
|
||||||
|
params.maxLinesPerMessage,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
params.chunkMode,
|
||||||
|
params.silent,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Discord thread names are capped at 100 characters. */
|
/** Discord thread names are capped at 100 characters. */
|
||||||
const DISCORD_THREAD_NAME_LIMIT = 100;
|
const DISCORD_THREAD_NAME_LIMIT = 100;
|
||||||
|
|
||||||
@@ -194,35 +219,25 @@ export async function sendMessageDiscord(
|
|||||||
chunkMode,
|
chunkMode,
|
||||||
opts.silent,
|
opts.silent,
|
||||||
);
|
);
|
||||||
for (const chunk of afterMediaChunks) {
|
await sendDiscordThreadTextChunks({
|
||||||
await sendDiscordText(
|
rest,
|
||||||
rest,
|
threadId,
|
||||||
threadId,
|
chunks: afterMediaChunks,
|
||||||
chunk,
|
request,
|
||||||
undefined,
|
maxLinesPerMessage: accountInfo.config.maxLinesPerMessage,
|
||||||
request,
|
chunkMode,
|
||||||
accountInfo.config.maxLinesPerMessage,
|
silent: opts.silent,
|
||||||
undefined,
|
});
|
||||||
undefined,
|
|
||||||
chunkMode,
|
|
||||||
opts.silent,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (const chunk of remainingChunks) {
|
await sendDiscordThreadTextChunks({
|
||||||
await sendDiscordText(
|
rest,
|
||||||
rest,
|
threadId,
|
||||||
threadId,
|
chunks: remainingChunks,
|
||||||
chunk,
|
request,
|
||||||
undefined,
|
maxLinesPerMessage: accountInfo.config.maxLinesPerMessage,
|
||||||
request,
|
chunkMode,
|
||||||
accountInfo.config.maxLinesPerMessage,
|
silent: opts.silent,
|
||||||
undefined,
|
});
|
||||||
undefined,
|
|
||||||
chunkMode,
|
|
||||||
opts.silent,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw await buildDiscordSendError(err, {
|
throw await buildDiscordSendError(err, {
|
||||||
|
|||||||
Reference in New Issue
Block a user