From 5bb927af05da70475b604b2f67fc1bbe1b3745c4 Mon Sep 17 00:00:00 2001 From: Tymon Date: Wed, 14 Dec 2022 01:15:10 +0100 Subject: [PATCH] Hopefully temporary (probably not) fix --- src/Chat.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Chat.ts b/src/Chat.ts index f6f1c1f..d24b6f8 100644 --- a/src/Chat.ts +++ b/src/Chat.ts @@ -45,7 +45,7 @@ export default class Chat { #client: Client; public characterId: string; - public characterInternalId: string; + public characterInternalId?: string; public historyId: string; constructor(client: Client, id: string, history: any) { @@ -53,9 +53,9 @@ export default class Chat { this.characterId = id; this.historyId = history.external_id; - this.characterInternalId = history.participants.find( - (participant: any) => participant.is_human === false - ).user.username; + // this.characterInternalId = history.participants.find( + // (participant: any) => participant.is_human === false + // ).user.username; } /** @@ -84,6 +84,11 @@ export default class Chat { * @returns Object with replies */ public async sendMessage(message: string): Promise { + if (!this.characterInternalId) + this.characterInternalId = ( + await this.#client.fetchCharacterInfo(this.characterId) + ).participant__user__username; + const payload = { history_external_id: this.historyId, character_external_id: this.characterId,