Created
August 21, 2024 00:38
-
-
Save mathislajs/9d70c37b161deb1355beb7af2027ba74 to your computer and use it in GitHub Desktop.
googleforms-discordwebhook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onFormSubmit(e) { | |
const webhookUrl = 'YOUR_DISCORD_WEBHOOK_URL'; // Replace with your Discord webhook URL | |
const formResponses = e.values; | |
const embed = { | |
title: "New Form Submission", | |
fields: [], | |
color: 7506394, | |
}; | |
// Add form responses to embed fields | |
for (let i = 0; i < formResponses.length; i++) { | |
embed.fields.push({ | |
name: `Question ${i + 1}`, | |
value: formResponses[i], | |
inline: false, | |
}); | |
} | |
const payload = JSON.stringify({ embeds: [embed] }); | |
const options = { | |
method: 'post', | |
contentType: 'application/json', | |
payload: payload, | |
}; | |
UrlFetchApp.fetch(webhookUrl, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment