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

@@ -1,6 +1,6 @@
{ {
"name": "legica-dana", "name": "legica-dana",
"version": "2.1.1", "version": "2.1.2",
"main": "src/app.ts", "main": "src/app.ts",
"scripts": { "scripts": {
"start": "bun run src/app.ts", "start": "bun run src/app.ts",

View File

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