I found code that uses D.I.S.C.O.R.D. Webhook to Google Forms and posts the answers into one channel but I couldn't wrap my head around getting specific answers only getting posted. Ex.) 1st Sections has 4 Questions and each question leads to another Sections based on the answer so 5 Sections in total, With that outcome I wanted to only obtain Section 1 Answer and the Section I went to (2,3,4,5).
Here is the code that I found, I'll really appreciate help.
Code:
var POST_URL = "WEBHOOK";
function onSubmit(e) {
var form = FormApp.getActiveForm();
var allResponses = form.getResponses();
var latestResponse = allResponses[allResponses.length - 1];
var response = latestResponse.getItemResponses();
var items = [];
for (var i = 0; i < response.length; i++) {
var question = response[i].getItem().getTitle();
var answer = response[i].getResponse();
try {
var parts = answer.match(/[\s\S]{1,1024}/g) || [];
} catch (e) {
var parts = answer;
}
if (answer == "") continue;
for (var j = 0; j < parts.length; j++) {
if (j == 0) items.push({
"name": question,
"value": parts[j],
"inline": false
});
else items.push({
"name": question.concat(" (cont.)"),
"value": parts[j],
"inline": false
});
}
}
var options = {
"method": "post",
"headers": {"Content-Type": "application/json"},
"payload": JSON.stringify({
"content": " ",
"embeds": [{
"title": "**Incoming Form Submission**",
"color": 15844367,
"fields": items,
"footer": {
"text": "Thank You for your time! :)"
}
}]
})
};
UrlFetchApp.fetch(POST_URL, options);
};