Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var POST_URL = "https://discordapp.com/api/webhooks/653638482052513793/aPsPaWlGYRaOZWoFcI3M5UQbBz5uwlET2tQQJnOu-FLTpNHH6uvrdRaJXAfIcCSBq8_P";
- 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({
- "embeds": [{
- "title": "Support Request",
- "fields": items,
- "footer": {
- "text": "@632456200943960084"
- }
- }]
- })
- };
- UrlFetchApp.fetch(POST_URL, options);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement