try..catch the channels

This commit is contained in:
Fran Jurmanović
2025-08-13 19:48:49 +02:00
parent 985ccf3e8a
commit ab17126b76
2 changed files with 32 additions and 29 deletions

View File

@@ -41,36 +41,39 @@ export async function sendDiscordMessage(
)}`
);
}
const promises = client.channels.cache.map(async (channel) => {
try {
if (channel.type !== "text") return null;
const embeddedMessage = new MessageEmbed().setTitle(title).setImage(img);
const msg = await (channel as TextChannel).send(embeddedMessage);
const reactions = [
"1⃣",
"2⃣",
"3⃣",
"4⃣",
"5⃣",
"6⃣",
"7⃣",
"8⃣",
"9⃣",
"🔟",
];
for (const reaction of reactions) {
try {
await msg.react(reaction);
} catch {
console.error(`Reaction ${reaction} to channel ${channel.id} failed.`);
try {
const promises = client.channels.cache.map(async (channel) => {
try {
if (channel.type !== "text") return null;
const embeddedMessage = new MessageEmbed().setTitle(title).setImage(img);
const msg = await (channel as TextChannel).send(embeddedMessage);
const reactions = [
"1⃣",
"2⃣",
"3⃣",
"4⃣",
"5⃣",
"6⃣",
"7⃣",
"8⃣",
"9⃣",
"🔟",
];
for (const reaction of reactions) {
try {
await msg.react(reaction);
} catch {
console.error(`Reaction ${reaction} to channel ${channel.id} failed.`);
}
}
} catch (err) {
console.error(`Message to channel ${channel.id} failed.`);
}
} catch (err) {
console.error(`Message to channel ${channel.id} failed.`);
}
});
await Promise.all(promises);
});
await Promise.all(promises);
} catch (err) {
console.error(err);
}
}
/**