Skip to content

Instantly share code, notes, and snippets.

@dorktoast
Created June 1, 2023 06:40
Show Gist options
  • Select an option

  • Save dorktoast/5ceb0f1a0504ce8a76b9e64f71ab9129 to your computer and use it in GitHub Desktop.

Select an option

Save dorktoast/5ceb0f1a0504ce8a76b9e64f71ab9129 to your computer and use it in GitHub Desktop.
Send a Discord message via Apps Script
function PostDiscordMessage(message) {
// Target Data
var discordUrl = 'https://discord.com/api/webhooks/YOUR_WEBHOOK_URL';
// replace pings with appropriate IDs
message = message.ToString().replace("@SomeRole","<@&976180323052294245>");
var payload = JSON.stringify({content: message});
var params = {
headers: {
'Content-Type': 'application/json'
},
method: "POST",
payload: payload,
muteHttpExceptions: true
};
var response = UrlFetchApp.fetch(discordUrl, params);
Logger.log(response.getContentText());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment