Skip to content

Commit

Permalink
feat: adds endpoint to convert GitHub webhook to prettier Discord web…
Browse files Browse the repository at this point in the history
…hook
  • Loading branch information
ViMaSter committed Oct 5, 2024
1 parent 74645dc commit db51049
Show file tree
Hide file tree
Showing 3 changed files with 460 additions and 0 deletions.
22 changes: 22 additions & 0 deletions host.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ export const hostPage = () => {
return res.sendFile("version.html", { root: "public/views" });
});

app.post("/webhook", async (req, res) => {
if (req.body.includes("No player-facing changes")) {
return;
}

const discordBody = convert(req.body);

try {
const discordRes = await fetch(process.env.DISCORD_RELEASE_WEBHOOK_URL, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(discordBody)
});

return res.status(discordRes.status).send(discordRes.statusText);
} catch (error) {
return res.status(500).send(error);
}
});

app.post("/contact", (req, res) => {
if (req.query.sendEmail != "" && req.query.sendEmail != true) {
return;
Expand Down
Loading

0 comments on commit db51049

Please sign in to comment.