@@ -90,7 +90,7 @@ const AIConfig: Required<ConfigureAI> = {
9090 const isMe = ( id : string ) => id === message . client . user . id ;
9191
9292 const conversation : AiMessage = recentMessages
93- . filter ( ( msg ) => msg . content && ( ! msg . author . bot || isMe ( msg . author . id ) ) )
93+ . filter ( ( msg ) => msg . content && ( isMe ( msg . author . id ) || ! msg . author . bot ) )
9494 . reverse ( )
9595 . map ( ( msg ) => ( {
9696 role : isMe ( msg . author . id ) ? 'assistant' : 'user' ,
@@ -108,6 +108,10 @@ const AIConfig: Required<ConfigureAI> = {
108108 } ) ) ,
109109 } ) ) ;
110110
111+ const ref = message . reference
112+ ? await message . fetchReference ( ) . catch ( ( ) => null )
113+ : null ;
114+
111115 return [
112116 ...conversation ,
113117 {
@@ -116,14 +120,24 @@ const AIConfig: Required<ConfigureAI> = {
116120 authorId : message . author . id ,
117121 authorName : message . author . username ,
118122 authorAvatar : message . author . displayAvatarURL ( ) ,
123+ referencedMessageId : ref ?. id ?? null ,
124+ referencedMessageContent : ref ?. content ?? null ,
119125 } ,
120126 createdAt : message . createdAt ,
121127 content : message . content ,
122- experimental_attachments : message . attachments . map ( ( attachment ) => ( {
123- url : attachment . url ,
124- name : attachment . name ,
125- contentType : attachment . contentType || undefined ,
126- } ) ) ,
128+ experimental_attachments : message . attachments
129+ . map ( ( attachment ) => ( {
130+ url : attachment . url ,
131+ name : attachment . name ,
132+ contentType : attachment . contentType || undefined ,
133+ } ) )
134+ . concat (
135+ ref ?. attachments . map ( ( attachment ) => ( {
136+ url : attachment . url ,
137+ name : attachment . name ,
138+ contentType : attachment . contentType || undefined ,
139+ } ) ) ?? [ ] ,
140+ ) ,
127141 } ,
128142 ] as AiMessage ;
129143 } ,
0 commit comments