Help! Trying to post to Discord using Google Scripts
I'm trying to set up a webhook from gingr to discord using google scripts. What am I doing wrong? I took the url from google and put that into gingr, and I put the webhook url from discord and put that into this code (redacted for this post)
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 GOES 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_in" ) {
sheet.appendRow([dog, last, breed, pic]);
UrlFetchApp.fetch(url, params);
}
}
-
If you need any help with apis, go to https://discord.gg/discord-api
There might be some api issues right now. https://status.discordapp.com0
請登入寫評論。
評論
1 條評論