From 465819e1c66c74b38ab86e2358f0159d1c86027d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=B7=AF=E8=B7=AF?= Date: Wed, 4 Mar 2026 09:13:20 +0800 Subject: [PATCH] feat(discord): support referenced/quoted messages in replies When a user replies to a message in Discord, the bot now reads m.ReferencedMessage and prepends its content to the incoming message as '[quoted message from Username]: content'. This gives the LLM full context of what message the user is replying to, enabling meaningful follow-up conversations. --- pkg/channels/discord/discord.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/channels/discord/discord.go b/pkg/channels/discord/discord.go index 1de910c83..0708afc69 100644 --- a/pkg/channels/discord/discord.go +++ b/pkg/channels/discord/discord.go @@ -338,6 +338,15 @@ func (c *DiscordChannel) handleMessage(s *discordgo.Session, m *discordgo.Messag content = c.stripBotMention(content) } + // Prepend referenced (quoted) message content if this is a reply + if m.MessageReference != nil && m.ReferencedMessage != nil { + refContent := m.ReferencedMessage.Content + if refContent != "" { + content = fmt.Sprintf("[quoted message from %s]: %s\n\n%s", + m.ReferencedMessage.Author.Username, refContent, content) + } + } + senderID := m.Author.ID mediaPaths := make([]string, 0, len(m.Attachments))