Skip to content

Instantly share code, notes, and snippets.

@remoblaser
Last active March 6, 2018 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remoblaser/5d1bbf2c3d267040a240460fc6cd80d5 to your computer and use it in GitHub Desktop.
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
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