-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7450de
commit 0869e12
Showing
3 changed files
with
20 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
require("dotenv").config() | ||
const axios = require("axios") | ||
const router = require("express").Router() | ||
require("dotenv").config(); | ||
const axios = require("axios"); | ||
const router = require("express").Router(); | ||
|
||
router.post("/:webhookId", async (req, res) => { | ||
const webhookUrl = `${process.env.DISCORD_WEBHOOK_URL}/${req.params.webhookId}/${process.env.DISCORD_WEBHOOK_TOKEN}` | ||
const webhookData = req.body | ||
const webhookUrl = `${process.env.DISCORD_WEBHOOK_URL}/${req.params.webhookId}/${process.env.DISCORD_WEBHOOK_TOKEN}`; | ||
const webhookData = req.body; | ||
try { | ||
await axios.post(webhookUrl, webhookData, { | ||
params: req.query, | ||
headers: req.headers, | ||
}) | ||
res.status(200).send("Webhook sent successfully") | ||
return | ||
} catch (error) { | ||
console.error(error) | ||
res.status(500).send("Internal server error") | ||
return | ||
}); | ||
res.status(200).send("Webhook sent successfully"); | ||
return; | ||
} | ||
}) | ||
catch (error) { | ||
console.error(error); | ||
res.status(500).send("Internal server error"); | ||
return; | ||
} | ||
}); | ||
|
||
module.exports = router | ||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters