Fix, pgboss connection issue

This commit is contained in:
KMKoushik
2024-06-12 18:10:01 +10:00
parent 48890c7409
commit ee93855cc0
3 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import { env } from "~/env";
export async function sendToDiscord(message: string) {
if (!env.DISCORD_WEBHOOK_URL) {
console.error(
"Discord webhook URL is not defined in the environment variables. So printing the message to the console."
);
console.log("Message: ", message);
return;
}
const webhookUrl = env.DISCORD_WEBHOOK_URL;
const response = await fetch(webhookUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ content: message }),
});
if (response.ok) {
console.log("Message sent to Discord successfully.");
} else {
console.error("Failed to send message to Discord:", response.statusText);
}
return;
}