Add chat history limit

This commit is contained in:
Hri7566 2024-08-03 07:16:30 -04:00
parent c94069bb37
commit 2590f161c6
1 changed files with 6 additions and 0 deletions

View File

@ -1110,6 +1110,12 @@ export class Channel extends EventEmitter {
this.sendArray([outgoing]); this.sendArray([outgoing]);
this.chatHistory.push(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); await saveChatHistory(this.getID(), this.chatHistory);
} }