Discord: align embed fallback in thread starter parsing

This commit is contained in:
Shakker
2026-02-25 23:50:41 +00:00
committed by Shakker
parent 39cc547f74
commit a0a229a3bb
4 changed files with 93 additions and 4 deletions

View File

@@ -7,7 +7,11 @@ import { buildAgentSessionKey } from "../../routing/resolve-route.js";
import { truncateUtf16Safe } from "../../utils.js";
import type { DiscordChannelConfigResolved } from "./allow-list.js";
import type { DiscordMessageEvent } from "./listeners.js";
import { resolveDiscordChannelInfo, resolveDiscordMessageChannelId } from "./message-utils.js";
import {
resolveDiscordChannelInfo,
resolveDiscordEmbedText,
resolveDiscordMessageChannelId,
} from "./message-utils.js";
export type DiscordThreadChannel = {
id: string;
@@ -172,7 +176,7 @@ export async function resolveDiscordThreadStarter(params: {
Routes.channelMessage(messageChannelId, params.channel.id),
)) as {
content?: string | null;
embeds?: Array<{ description?: string | null }>;
embeds?: Array<{ title?: string | null; description?: string | null }>;
member?: { nick?: string | null; displayName?: string | null };
author?: {
id?: string | null;
@@ -184,7 +188,9 @@ export async function resolveDiscordThreadStarter(params: {
if (!starter) {
return null;
}
const text = starter.content?.trim() ?? starter.embeds?.[0]?.description?.trim() ?? "";
const content = starter.content?.trim() ?? "";
const embedText = resolveDiscordEmbedText(starter.embeds?.[0]);
const text = content || embedText;
if (!text) {
return null;
}