이건 Python이 잘못했다다
This commit is contained in:
parent
2d2e546673
commit
ca946990e1
41 changed files with 3081 additions and 964 deletions
39
app/lib/discord.ts
Normal file
39
app/lib/discord.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { getMealInfo } from "./meal";
|
||||
|
||||
const WEBHOOK_URL = process.env.DISCORD_WEBHOOK_URL as string;
|
||||
|
||||
export async function Discord(MLSV_YMD: string) {
|
||||
const mealInfo = await getMealInfo(MLSV_YMD);
|
||||
//const isVTS = vts.VTS임(MLSV_YMD);
|
||||
|
||||
const data = {
|
||||
// To include VTS info, uncomment and define isVTS:
|
||||
// content: `${MLSV_YMD.slice(0, 4)}년 ${MLSV_YMD.slice(4, 6)}월 ${MLSV_YMD.slice(6, 8)}일 급식 정보${isVTS ? " | with V.T.S." : ""}`,
|
||||
content: `${MLSV_YMD.slice(0, 4)}년 ${MLSV_YMD.slice(
|
||||
4,
|
||||
6
|
||||
)}월 ${MLSV_YMD.slice(6, 8)}일 급식 정보`,
|
||||
username: "@today.isangjeong",
|
||||
embeds: [
|
||||
{
|
||||
title: "🏫 | 인천상정중학교",
|
||||
description: `🔥 ${mealInfo.kcal}\n\n${mealInfo.meal}`,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
console.log("🏓 | Sending Payload");
|
||||
const response = await fetch(WEBHOOK_URL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error("Error sending Discord webhook:", response.statusText);
|
||||
} else {
|
||||
console.log(`✨ | Payload successfully, code ${response.status}`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue