Created
July 2, 2021 08:45
-
-
Save CUEICHI/89f9c5ab1a6e9f39c9b165724fb6a06d to your computer and use it in GitHub Desktop.
GAS sample for DISCORD/SLACK WebHook
This file contains hidden or 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
| SLACK = #SLACK Webhook URL | |
| DISCORD = #discord webhook URL | |
| function discordMsg(msg){ | |
| var payload = { | |
| username : BOTNAME, | |
| content : msg | |
| }; | |
| var options = { | |
| 'method' : 'post', | |
| 'contentType': 'application/json', | |
| 'payload' : JSON.stringify(payload) | |
| }; | |
| var res = UrlFetchApp.fetch(DISCORD, options); | |
| console.log(options); | |
| console.log(res.getHeaders()); | |
| } | |
| function slackMsg(msg){ | |
| var payload = { | |
| username : BOTNAME, | |
| channel : CHANNEL, | |
| text : msg | |
| }; | |
| var options = { | |
| 'method' : 'post', | |
| 'contentType': 'application/json', | |
| 'payload' : JSON.stringify(payload) | |
| }; | |
| var res = UrlFetchApp.fetch(SLACK, options); | |
| console.log(options); | |
| console.log(res.getHeaders()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment