我正在使用一些脚本通过Google Apps脚本向不和谐的人发送消息...我使用了诸如以下功能:
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());
}
一切正常运行了数周,但是自从2或3周以来,什么都没有发送出去了……有人能帮我了解发生了什么吗?
非常感谢:)
答案 0 :(得分:2)
以下修改如何?
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}
错误。如果这不是您问题的直接解决方案,我深表歉意。