diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/LimitedMap.ts b/src/equicordplugins/messageLoggerEnhanced/utils/LimitedMap.ts index 38ee9e09..f8f2aa48 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/LimitedMap.ts +++ b/src/equicordplugins/messageLoggerEnhanced/utils/LimitedMap.ts @@ -25,7 +25,10 @@ export class LimitedMap { set(key: K, value: V) { if (settings.store.cacheLimit > 0 && this.map.size >= settings.store.cacheLimit) { // delete the first entry - this.map.delete(this.map.keys().next().value); + const firstKey = this.map.keys().next().value; + if (firstKey !== undefined) { + this.map.delete(firstKey); + } } this.map.set(key, value); }