Discord Webhook not working #80934
Unanswered
Mortveiare
asked this question in
API and Webhooks
Replies: 2 comments
-
I think the problem has to do with the appscript.json file in the project. Discord webhooks requires I made the changes to my code, but i have not been able to get my discord to receive the new message. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Select Topic Area
Question
Body
I am trying to send a notification to discord using a webhook on good sheets. Whereas the script seems to be running fine and tests fine, no notifications are going through. The idea is, every time a new form is submitted, which is pushed to google sheets, discord will notify users in the designated webhooked channel.
function onEdit(e) {
// Check if the event object and range are defined
if (!e || !e.range) {
console.log("No event object or range found. Function must be triggered by an edit.");
return;
}
var discordUrl = "webhook example here";
const range = e.range;
var sheetname = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
var message = sheetname + " " + range.getA1Notation() + " edited on " + new Date();
var payload = JSON.stringify({ content: message });
var params = {
method: "POST",
payload: payload,
muteHttpExceptions: true,
contentType: "application/json"
};
var response = UrlFetchApp.fetch(POST_URL, params);
}
Beta Was this translation helpful? Give feedback.
All reactions