Skip to content

Commit 8a1ec44

Browse files
committed
feat: update to use parallel processing for posting
1 parent 7473648 commit 8a1ec44

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/messages/send.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ export default async function sendMessage(body: Body): Promise<void> {
2929
const webhookUrls = env.DISCORD_WEBHOOK_URL.split(',');
3030
let successCount = 0;
3131

32-
for (const url of webhookUrls) {
33-
const success = await sendWebhook(body, url);
34-
if (success) {
35-
successCount++;
36-
} else {
37-
console.error(`Failed to send webhook: ${url}`);
38-
}
39-
}
32+
const results = await Promise.all(
33+
webhookUrls.map(async (url) => {
34+
const success = await sendWebhook(body, url);
35+
if (!success) {
36+
console.error(`Failed to send webhook: ${url}`);
37+
}
38+
return success;
39+
}),
40+
);
41+
42+
successCount = results.filter(Boolean).length;
4043

4144
if (env.ENABLE_LOGGER) {
4245
// Log the number of successful webhooks

0 commit comments

Comments
 (0)