From 2590f161c6c1071c2ef824987aa1ef6ef5f7b8a3 Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Sat, 3 Aug 2024 07:16:30 -0400 Subject: [PATCH] Add chat history limit --- src/channel/Channel.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/channel/Channel.ts b/src/channel/Channel.ts index ae0c486..22d2e65 100644 --- a/src/channel/Channel.ts +++ b/src/channel/Channel.ts @@ -1110,6 +1110,12 @@ export class Channel extends EventEmitter { this.sendArray([outgoing]); this.chatHistory.push(outgoing); + + // Limit chat history to 512 messages + if (this.chatHistory.length > 512) { + this.chatHistory.splice(0, this.chatHistory.length - 512); + } + await saveChatHistory(this.getID(), this.chatHistory); }