@@ -90,7 +90,7 @@ const AIConfig: Required<ConfigureAI> = {
90
90
const isMe = ( id : string ) => id === message . client . user . id ;
91
91
92
92
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 ) )
94
94
. reverse ( )
95
95
. map ( ( msg ) => ( {
96
96
role : isMe ( msg . author . id ) ? 'assistant' : 'user' ,
@@ -108,6 +108,10 @@ const AIConfig: Required<ConfigureAI> = {
108
108
} ) ) ,
109
109
} ) ) ;
110
110
111
+ const ref = message . reference
112
+ ? await message . fetchReference ( ) . catch ( ( ) => null )
113
+ : null ;
114
+
111
115
return [
112
116
...conversation ,
113
117
{
@@ -116,14 +120,24 @@ const AIConfig: Required<ConfigureAI> = {
116
120
authorId : message . author . id ,
117
121
authorName : message . author . username ,
118
122
authorAvatar : message . author . displayAvatarURL ( ) ,
123
+ referencedMessageId : ref ?. id ?? null ,
124
+ referencedMessageContent : ref ?. content ?? null ,
119
125
} ,
120
126
createdAt : message . createdAt ,
121
127
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
+ ) ,
127
141
} ,
128
142
] as AiMessage ;
129
143
} ,
0 commit comments