Reputation: 135
I have a google forms script that pulls all the information submitted and posts a new forum thread. In the content, it pings a user, and a role, and then posts embedded information pulled from the google forms entry. The ping itself seems to work as the text is highlighted as it should be, however nobody gets invited in to the thread by the ping and nobody gets notifications.
If I manually ping people, the invites are sent out appropriately.
I know permissions are set up correctly because I have another webhook in a normal channel that uses almost the exact same code but it's a standard text channel and works fine. I set the permissions up to be exactly the same in this channel. Pings and notifications work as expected.
Here's the code for the script.
function onFormSubmit(e) {
var webhookUrl = 'WEBHOOK_URL_HERE';
var responses = e.response.getItemResponses();
var embedFields = [];
var responseDate = e.response.getTimestamp();
var formattedDate = Utilities.formatDate(responseDate, Session.getScriptTimeZone(), "MMMM dd, yyyy");
var discordUserName = 'username';
var characterName = 'charactername';
var discordUserID = 'userID'
responses.forEach(function(response) {
var question = response.getItem().getTitle();
var answer = response.getResponse();
if (question == "Player discord username (actual username not channel nickname)")
{
discordUserName = answer;
}
else if (question == "Player Name")
{
characterName = answer;
}
else if (question == "Discord User ID")
{
discordUserID = answer;
}
else
{
embedFields.push({name: question, value: answer || 'N/A', inline: false});
}
});
var payload = JSON.stringify({
content: `<@${discordUserID}> <@&931744802729513001> New Review!`,
embeds: [{
title: `Details (Submitted: ${formattedDate})`,
color: 5814783, // You can change this to any color you prefer
fields: embedFields
}],
thread_name: discordUserName + ' - ' + characterName
});
var params = {
method: "post",
contentType: "application/json",
payload: payload
};
// Posting the embed message to Discord
UrlFetchApp.fetch(webhookUrl, params);
}
I'm entirely unsure where to go from here or if this is even possible.
Upvotes: 0
Views: 282