exception handler

This commit is contained in:
Fran Jurmanović
2023-10-01 14:26:13 +02:00
parent 2b192b9f94
commit c2ab9c9ba8

View File

@@ -13,18 +13,22 @@ class ClientController {
}; };
private sendMessage = async (): Promise<void> => { private sendMessage = async (): Promise<void> => {
const href = await getFirstHtml(); try {
const { img, title } = await getImgTitle(href); const href = await getFirstHtml();
const { img, title } = await getImgTitle(href);
this.client.channels.cache.forEach(async (channel) => {
if (channel.type !== "text") return null; this.client.channels.cache.forEach(async (channel) => {
const embeddedMessage = new MessageEmbed().setTitle(title).setImage(img); if (channel.type !== "text") return null;
const msg = await (channel as TextChannel).send(embeddedMessage); const embeddedMessage = new MessageEmbed().setTitle(title).setImage(img);
const reactions = ["1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣", "🔟"]; const msg = await (channel as TextChannel).send(embeddedMessage);
for (const reaction of reactions) { const reactions = ["1⃣", "2⃣", "3⃣", "4⃣", "5⃣", "6⃣", "7⃣", "8⃣", "9⃣", "🔟"];
await msg.react(reaction); for (const reaction of reactions) {
} await msg.react(reaction);
}); }
});
} catch (err) {
console.error(err);
}
}; };
} }