Skip to content

Commit

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

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,
}));

try {
const results = await Promise.all(stempelkarten);
const files = results.map((attachment, index) => ({
name: `stempelkarte/${ofMember.nickname}-${index}.png`,
attachment,
}));

await command.reply({
files,
});
Expand Down

0 comments on commit 22836e4

Please sign in to comment.