From 18175bd2313e5d3919510e0417103317918611ec Mon Sep 17 00:00:00 2001 From: vrtnd Date: Fri, 26 Jul 2024 11:45:45 +0300 Subject: [PATCH] discord message fix --- src/utils/discord.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/discord.ts b/src/utils/discord.ts index 3ad80baa..f768eb00 100644 --- a/src/utils/discord.ts +++ b/src/utils/discord.ts @@ -2,13 +2,19 @@ import fetch from "node-fetch"; export async function sendDiscordText(message: string): Promise { try { - await fetch(process.env.DISCORD_WEBHOOK as string, { + const res = await fetch(process.env.DISCORD_WEBHOOK as string, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ content: message }), }); + if (!res.ok) { + console.error("Failed to send message to Discord:", res.statusText); + } + if (res.ok) { + console.log("Message sent to Discord:", message); + } } catch (error) { console.error("Failed to send message to Discord:", error); }