Skip to content

Commit

Permalink
Log if failure
Browse files Browse the repository at this point in the history
  • Loading branch information
holzmaster committed Dec 13, 2024
1 parent 543c208 commit 383c23e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/commands/stempelkarte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,24 @@ export default class StempelkarteCommand implements ApplicationCommand {
stempelkarten.push(drawStempelkarteBackside(subjectAvatarUrl, avatarUrls));
}

const results = (await Promise.allSettled(stempelkarten)).filter(
const allResults = await Promise.allSettled(stempelkarten);

const results = allResults.filter(
result => result.status === "fulfilled",
) as PromiseFulfilledResult<Buffer>[];

if (results.length === 0) {
await command.reply({
content: "Es ist ein Fehler aufgetreten. Bitte versuche es später erneut.",
});

log.error(
allResults.map(e => ("reason" in e ? e.reason : undefined)),
"No stempelkarten were created",
);
return;
}

const files = results.map((result, index) => ({
name: `stempelkarte/${ofMember.nickname}-${index}.png`,
attachment: result.value,
Expand Down

0 comments on commit 383c23e

Please sign in to comment.