import { parseDiscordTarget } from "./target-parsing.js";
export function normalizeDiscordMessagingTarget(raw: string): string | undefined { // Default bare IDs to channels so routing is stable across tool actions. const target = parseDiscordTarget(raw, { defaultKind: "channel" }); return target?.normalized;
}
/** * Normalize a Discord outbound target for delivery. Bare numeric IDs are * prefixed with "channel:" to avoid the ambiguous-target error in * parseDiscordTarget. All other formats pass through unchanged.
*/
export function normalizeDiscordOutboundTarget(
to?: string,
): { ok: true; to: string } | { ok: false; error: Error } { const trimmed = to?.trim(); if (!trimmed) { return {
ok: false,
error: new Error( 'Discord recipient is required. Use "channel:<id>" for channels or "user:<id>" for DMs.',
),
};
} if (/^\d+$/.test(trimmed)) { return { ok: true, to: `channel:${trimmed}` };
} return { ok: true, to: trimmed };
}
export function looksLikeDiscordTargetId(raw: string): boolean { const trimmed = raw.trim(); if (!trimmed) { returnfalse;
} if (/^<@!?\d+>$/.test(trimmed)) { returntrue;
} if (/^(user|channel|discord):/i.test(trimmed)) { returntrue;
} if (/^\d{6,}$/.test(trimmed)) { returntrue;
} returnfalse;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-04)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.