From 177878fabe37598eb3bbdbe901b90c0495ff3269 Mon Sep 17 00:00:00 2001 From: Justin Oro Date: Sat, 5 Sep 2026 19:20:01 -0700 Subject: [PATCH] Respond to Discord replies to the bot without requiring its name --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 604bcee..1b8828a 100644 --- a/index.js +++ b/index.js @@ -115,6 +115,16 @@ function markActiveAiConversation(userId, channelId) { activeAiConversations.set(userId, { channelId: channelId, expiresAt: Date.now() + AI_ACTIVE_CONVO_MS }); } +async function isReplyToBot(message) { + if (!message.reference || !message.reference.messageId) return false; + try { + const refMessage = await message.channel.messages.fetch(message.reference.messageId); + return refMessage.author.id === client.user.id; + } catch (err) { + return false; + } +} + function getAiHistory(userId) { const entry = aiHistories.get(userId); if (!entry) return []; @@ -1609,7 +1619,9 @@ client.on("messageCreate", async (message) => { } else if (lower === "!help") { await handleHelp(message); } else if (!content.startsWith("!") && AI_ENABLED && - (TRIGGER_MENTION.test(content) || isActiveAiConversation(message.author.id, message.channelId))) { + (TRIGGER_MENTION.test(content) || + isActiveAiConversation(message.author.id, message.channelId) || + await isReplyToBot(message))) { if (canUseAI(message.author.id)) { try { const history = getAiHistory(message.author.id);