In this article, you will learn how you can easily and quickly Post Messages to Discord Channel via Google Apps Script & Webhooks.
Discord a hugely popular voice and text chat app for gamers. It provides text chat channels to support community connection, similar to Slack. The example below demonstrates how you can use webhooks and Google Apps Script to quickly post texts and Post Messages to Discord Channel (server).
Also checkRead Google Contacts with Google Apps Script Best Guide!
Go to your Discord channel, select settings, webhooks, and then click the “Create Webhook” button to get started. Note down the webhook’s URL. Now all you have to do to post a message to the channel is send an HTTP POST request to the webhook URL with a JSON message.
Code to Post Messages to Discord Channel:
function postMessageToDiscord(message) {
message = message || 'Hello World!';
var discordUrl = 'https://discordapp.com/api/webhooks/labnol/123';
var payload = JSON.stringify({ content: message });
var params = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
method: 'POST',
payload: payload,
muteHttpExceptions: true,
};
var response = UrlFetchApp.fetch(discordUrl, params);
Logger.log(response.getContentText());
}
You can use Webhooks and Google Apps Script to post Gmail messages, new tweets, YouTube subscriptions, weather updates, Bitcoin price updates, and anything else to your Discord channel.
from thetechxp https://ift.tt/xVK7XZD
via IFTTT
Comments
Post a Comment