Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Help Me Fix This Code

0 votes
asked Dec 7, 2019 by Lindsey
I'm trying to make a webhook connect to Discord. What do I need to fix in this code?

function doPost(e) {
  
  var hook = JSON.parse(e.postData.contents);
  var hooktype = hook.webhook_type;
  var data = hook.entity_data;
  var dog = data.animal_name;
  var last = data.o_last;
  var pic = data.image;
  var breed = data.breed_name;
  var type = data.type;
  var sheet = SpreadsheetApp.getActiveSheet();  
  var url = "DISCORD WEBHOOK URL WILL GO HERE";
  var params = {
    "method": "post",
    "payload": JSON.stringify({
        "username": dog,
        "content": "I'm going home!",
        "embeds": [{
          "title": "Reservation Type",
             "description": type,
             "fields": [
              {
                "name": dog,
                "value": last,
                "inline": true
              },
              {
                "name": breed,
                "inline": true
              }
            ],
          "image": {
            "url": pic
            }
          }]
        })
    };
  if ( hooktype == "check_out" ) {
    sheet.appendRow([dog, last, breed, pic]);
    UrlFetchApp.fetch(url, params);
    }
}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...