Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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": JSON.stringify(response.getResponse()),
- "inline": false
- });
- }
- var data = {
- "embeds": [{
- "title": "**New form submission** — " + (e.source.getTitle() != null && e.source.getTitle().length > 0 ? e.source.getTitle() : "Untitled Form"),
- "type": "rich",
- "fields": fields
- }]
- };
- var options = {
- method: "post",
- payload: JSON.stringify(data),
- contentType: "application/json; charset=utf-8",
- muteHttpExceptions: false,
- };
- Logger.log("Attempting to send:");
- Logger.log(JSON.stringify(data));
- var response = UrlFetchApp.fetch("DISCORDWEBHOOK", options);
- Logger.log(response.getContentText());
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement