Reputation: 117
I am using some scripts to send message to discord via google apps script... I used a function such as :
function postMessageToDiscord(){
message = "Hello World!";
var discordUrl = "https://discordapp.com/api/webhooks/XXXXX";
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());
}
Everything was working perfectly for weeks, but since 2 or 3 weeks, nothing is sent to discord anymore... Could someone help me to understand what's going on?
Thanks a lot :)
Upvotes: 2
Views: 2700
Reputation: 201553
How about the following modifications?
var params = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
method: "POST",
payload: payload,
muteHttpExceptions: true
};
var params = {
method: "POST",
payload: payload,
muteHttpExceptions: true,
contentType: "application/json"
};
var payload = JSON.stringify({content: message});
var payload = {content: message};
{"message": "Cannot send an empty message", "code": 50006}
occurs when your script is run.If this was not the direct solution of your issue, I apologize.
Upvotes: 4