File tree Expand file tree Collapse file tree 1 file changed +10
-19
lines changed Expand file tree Collapse file tree 1 file changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -2,25 +2,16 @@ require("dotenv").config()
2
2
const axios = require ( "axios" )
3
3
const router = require ( "express" ) . Router ( )
4
4
5
- router . get ( "/:webhookId" , async ( req , res ) => {
6
- console . log ( req )
7
- // only allow POST
8
- if ( req . method === "POST" ) {
9
- const webhookUrl = `${ process . env . DISCORD_WEBHOOK_URL } /${ req . params . webhookId } /${ process . env . DISCORD_WEBHOOK_TOKEN } `
10
- const webhookData = req . body
11
- try {
12
- console . log ( 'Sending webhook' , webhookUrl , webhookData )
13
- await axios . post ( webhookUrl , webhookData , { params : req . query } )
14
- console . log ( 'Webhook sent successfully' )
15
- res . status ( 200 ) . send ( "Webhook sent successfully" )
16
- return
17
- } catch ( error ) {
18
- console . error ( error )
19
- res . status ( 500 ) . send ( "Internal server error" )
20
- return
21
- }
22
- } else {
23
- res . status ( 405 ) . send ( "Method not allowed" )
5
+ router . post ( "/:webhookId" , async ( req , res ) => {
6
+ const webhookUrl = `${ process . env . DISCORD_WEBHOOK_URL } /${ req . params . webhookId } /${ process . env . DISCORD_WEBHOOK_TOKEN } `
7
+ const webhookData = req . body
8
+ try {
9
+ await axios . post ( webhookUrl , webhookData , { params : req . query } )
10
+ res . status ( 200 ) . send ( "Webhook sent successfully" )
11
+ return
12
+ } catch ( error ) {
13
+ console . error ( error )
14
+ res . status ( 500 ) . send ( "Internal server error" )
24
15
return
25
16
}
26
17
} )
You can’t perform that action at this time.
0 commit comments