From 807e7c9ce8a2610a8e95ac2ea9fe43eae78c9e6b Mon Sep 17 00:00:00 2001 From: metal Date: Mon, 30 Aug 2021 17:37:38 +0000 Subject: [PATCH] check lastEntry exists --- backend/src/plugins/Logs/util/log.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/plugins/Logs/util/log.ts b/backend/src/plugins/Logs/util/log.ts index 9092dfa9..c023f92e 100644 --- a/backend/src/plugins/Logs/util/log.ts +++ b/backend/src/plugins/Logs/util/log.ts @@ -110,11 +110,11 @@ export async function log( } } else { const msgEmbeds = msg.embeds; - const lastEntry = chunks[chunks.length - 1]; + const lastEntry = chunks.length > 0 ? chunks[chunks.length - 1] : null; if (!msgEmbeds || msgEmbeds.length === 0) continue; // check if the latest chunk is an embed, if not, make it one - if (typeof lastEntry !== "string" && lastEntry.embeds) { + if (typeof lastEntry !== "string" && lastEntry!.embeds) { (chunks[chunks.length - 1] as MessageOptions).embeds!.push(...msgEmbeds); } else { chunks.push({ embeds: msgEmbeds });