3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-21 16:55:03 +00:00

check lastEntry exists

This commit is contained in:
metal 2021-08-30 17:37:38 +00:00 committed by GitHub
parent 098e57c645
commit 807e7c9ce8

View file

@ -110,11 +110,11 @@ export async function log<TLogType extends keyof ILogTypeData>(
}
} 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 });