@@ -17,7 +17,7 @@ import { embeddingZeroVector } from "../../core/memory.ts";
17
17
import { MessageManager } from "./messages.ts" ;
18
18
import { VoiceManager } from "./voice.ts" ;
19
19
20
- import { IAgentRuntime } from "../../core/types.ts" ;
20
+ import { Character , IAgentRuntime } from "../../core/types.ts" ;
21
21
import chat_with_attachments from "./actions/chat_with_attachments.ts" ;
22
22
import joinvoice from "./actions/joinvoice.ts" ;
23
23
import leavevoice from "./actions/leavevoice.ts" ;
@@ -31,7 +31,7 @@ export class DiscordClient extends EventEmitter {
31
31
apiToken : string ;
32
32
private client : Client ;
33
33
private runtime : IAgentRuntime ;
34
- character : any ;
34
+ character : Character ;
35
35
private messageManager : MessageManager ;
36
36
private voiceManager : VoiceManager ;
37
37
@@ -182,29 +182,16 @@ export class DiscordClient extends EventEmitter {
182
182
console . error ( "Invalid user id or room id" ) ;
183
183
return ;
184
184
}
185
- const agentId = this . runtime . agentId ;
186
185
const userName = reaction . message . author . username ;
187
186
const name = reaction . message . author . displayName ;
188
- await Promise . all ( [
189
- this . runtime . ensureUserExists (
190
- agentId ,
191
- this . client . user . username ,
192
- this . runtime . character . name ,
193
- "discord"
194
- ) ,
195
- this . runtime . ensureUserExists (
196
- userIdUUID ,
197
- userName ,
198
- name ,
199
- "discord"
200
- ) ,
201
- this . runtime . ensureRoomExists ( roomId ) ,
202
- ] ) ;
203
-
204
- await Promise . all ( [
205
- this . runtime . ensureParticipantInRoom ( userIdUUID , roomId ) ,
206
- this . runtime . ensureParticipantInRoom ( agentId , roomId ) ,
207
- ] ) ;
187
+
188
+ await this . runtime . ensureConnection (
189
+ userIdUUID ,
190
+ roomId ,
191
+ userName ,
192
+ name ,
193
+ "discord"
194
+ ) ;
208
195
209
196
// Save the reaction as a message
210
197
await this . runtime . messageManager . createMemory ( {
@@ -259,37 +246,16 @@ export class DiscordClient extends EventEmitter {
259
246
`${ reaction . message . id } -${ user . id } -${ emoji } -removed`
260
247
) ;
261
248
262
- const agentId = this . runtime . agentId ;
263
249
const userName = reaction . message . author . username ;
264
250
const name = reaction . message . author . displayName ;
265
251
266
- console . log ( "reactionUUID" , reactionUUID ) ;
267
- console . log ( "userIdUUID" , userIdUUID ) ;
268
- console . log ( "roomId" , roomId ) ;
269
- console . log ( "agentId" , agentId ) ;
270
- console . log ( "userName" , userName ) ;
271
- console . log ( "name" , name ) ;
272
-
273
- await Promise . all ( [
274
- this . runtime . ensureUserExists (
275
- agentId ,
276
- this . client . user . username ,
277
- this . runtime . character . name ,
278
- "discord"
279
- ) ,
280
- this . runtime . ensureUserExists (
281
- userIdUUID ,
282
- userName ,
283
- name ,
284
- "discord"
285
- ) ,
286
- this . runtime . ensureRoomExists ( roomId ) ,
287
- ] ) ;
288
-
289
- await Promise . all ( [
290
- this . runtime . ensureParticipantInRoom ( userIdUUID , roomId ) ,
291
- this . runtime . ensureParticipantInRoom ( agentId , roomId ) ,
292
- ] ) ;
252
+ await this . runtime . ensureConnection (
253
+ userIdUUID ,
254
+ roomId ,
255
+ userName ,
256
+ name ,
257
+ "discord"
258
+ ) ;
293
259
294
260
try {
295
261
// Save the reaction removal as a message
0 commit comments