Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. var POST_URL = "https://discordapp.com/api/webhooks/653638482052513793/aPsPaWlGYRaOZWoFcI3M5UQbBz5uwlET2tQQJnOu-FLTpNHH6uvrdRaJXAfIcCSBq8_P";
  2.  
  3. function onSubmit(e) {
  4. var form = FormApp.getActiveForm();
  5. var allResponses = form.getResponses();
  6. var latestResponse = allResponses[allResponses.length - 1];
  7. var response = latestResponse.getItemResponses();
  8. var items = [];
  9.  
  10. for (var i = 0; i < response.length; i++) {
  11. var question = response[i].getItem().getTitle();
  12. var answer = response[i].getResponse();
  13. try {
  14. var parts = answer.match(/[\s\S]{1,1024}/g) || [];
  15. } catch (e) {
  16. var parts = answer;
  17. }
  18.  
  19. if (answer == "") {
  20. continue;
  21. }
  22. for (var j = 0; j < parts.length; j++) {
  23. if (j == 0) {
  24. items.push({
  25. "name": question,
  26. "value": parts[j],
  27. "inline": false,
  28. });
  29. } else {
  30. items.push({
  31. "name": question.concat(" (cont.)"),
  32. "value": parts[j],
  33. "inline": false
  34. });
  35. }
  36. }
  37. }
  38.  
  39. var options = {
  40. "method": "post",
  41. "headers": {
  42. "Content-Type": "application/json"
  43. },
  44. "payload": JSON.stringify({
  45. "embeds": [{
  46. "title": "Support Request",
  47. "fields": items,
  48. "footer": {
  49. "text": "@632456200943960084"
  50. }
  51. }]
  52. })
  53. };
  54.  
  55. UrlFetchApp.fetch(POST_URL, options);
  56. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement