diff --git a/google apps script/scripts/gmail.gs b/google apps script/scripts/gmail.gs index 5f1de01..a3d4856 100644 --- a/google apps script/scripts/gmail.gs +++ b/google apps script/scripts/gmail.gs @@ -2,7 +2,7 @@ Iterates through all emails labeled with "Send til Discord" and sends a message to discord through discord webhooks */ -var webhookUrl = 'yeet'; // Insert your webhook url here +var webhookUrl = "yeet"; // Insert your webhook url here function processEmails() { var label = GmailApp.getUserLabelByName("Send til Discord"); @@ -10,7 +10,7 @@ function processEmails() { for (var i = threads.length - 1; i >= 0; i--) { var messages = threads[i].getMessages(); - var sender = messages[messages.length-1].getFrom(); + var sender = messages[messages.length - 1].getFrom(); sendToDiscord(sender); threads[i].removeLabel(label).refresh(); } @@ -18,11 +18,12 @@ function processEmails() { function sendToDiscord(sender) { var discordPayload = { - content: '<@267415183931080715> <@170506717140877312> Ny e-post fra: ' + sender - } - UrlFetchApp.fetch(webhookUrl', { - method: 'post', + content: + "<@&761538649786417152> <@&761538899289833472> Ny e-post fra: " + sender, + }; + UrlFetchApp.fetch(webhookUrl, { + method: "post", payload: JSON.stringify(discordPayload), - contentType: 'application/json' - }) + contentType: "application/json", + }); }