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);
}
}