Last active
March 6, 2018 12:45
-
-
Save remoblaser/5d1bbf2c3d267040a240460fc6cd80d5 to your computer and use it in GitHub Desktop.
This Google Forms Script takes all Fields from a Form and sends it to Discord via 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
function onFormSubmit(e) { | |
var fields = []; | |
for (i = 0; i < e.response.getItemResponses().length; i++) { | |
var response = e.response.getItemResponses()[i]; | |
fields.push({ | |
"name": response.getItem().getTitle(), | |
"value": response.getResponse(), | |
"inline": false | |
}); | |
} | |
var data = { | |
"embeds": [{ | |
"title": "Title for the Discord Embed", | |
"type": "rich", | |
"fields": fields | |
}] | |
}; | |
var options = { | |
method: "post", | |
payload: JSON.stringify(data), | |
contentType: "application/json; charset=utf-8", | |
muteHttpExceptions: true | |
}; | |
Logger.log("Attempting to send:"); | |
Logger.log(JSON.stringify(data)); | |
var response = UrlFetchApp.fetch("DISCORD_WEBHOOK_URL", options); | |
Logger.log(response.getContentText()); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment