fix(discord): respect replyToMode in threads

Previously, when replying in Discord threads, the replyToMode setting
was ignored because existingId was checked before replyToMode. This
caused reply references to be added even when replyToMode was set to
'off'.

This fix moves the replyToMode check before the existingId check,
ensuring that replyToMode: 'off' is respected in all contexts including
threads.
This commit is contained in:
Lalit Singh 2026-01-28 15:42:30 +01:00
parent 01e0d3a320
commit cd1480d637

View File

@ -11,7 +11,7 @@ export type ReplyReferencePlanner = {
export function createReplyReferencePlanner(options: {
replyToMode: ReplyToMode;
/** Existing thread/reference id (always used when present). */
/** Existing thread/reference id (used when present, unless replyToMode is "off"). */
existingId?: string;
/** Id to start a new thread/reference when allowed (e.g., parent message id). */
startId?: string;
@ -27,12 +27,12 @@ export function createReplyReferencePlanner(options: {
const use = (): string | undefined => {
if (!allowReference) return undefined;
if (options.replyToMode === "off") return undefined;
if (existingId) {
hasReplied = true;
return existingId;
}
if (!startId) return undefined;
if (options.replyToMode === "off") return undefined;
if (options.replyToMode === "all") {
hasReplied = true;
return startId;