3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 01:25:02 +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 { } else {
const msgEmbeds = msg.embeds; 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; if (!msgEmbeds || msgEmbeds.length === 0) continue;
// check if the latest chunk is an embed, if not, make it one // 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); (chunks[chunks.length - 1] as MessageOptions).embeds!.push(...msgEmbeds);
} else { } else {
chunks.push({ embeds: msgEmbeds }); chunks.push({ embeds: msgEmbeds });