gpt4 book ai didi

javascript - Discord Webhook 消息无法发送

转载 作者:行者123 更新时间:2023-11-30 10:58:32 30 4
gpt4 key购买 nike

所以我有一段时间前有人发布的这段代码。它已经完美地工作了一年了。它采用 google 形式的答案并将它们作为 webhook 发布到 discord channel 。现在从昨天开始,它不再工作了。脚本没有任何变化。

function onSubmit(e) {
var form = FormApp.getActiveForm();
var POST_URL = "****";
var allResponses = form.getResponses();
var latestResponse = allResponses[allResponses.length - 1];
var response = latestResponse.getItemResponses();
var items = [];

for (var i = 0; i < response.length; i++) {
var question = response[i].getItem().getTitle();
var answer = response[i].getResponse();
try {
var parts = answer.match(/[\s\S]{1,1024}/g) || [];
} catch (e) {
var parts = answer;
}

if (answer == "") {
continue;
}
for (var j = 0; j < parts.length; j++) {
if (j == 0) {
items.push({
"name": question,
"value": parts[j],
"inline": false
});
} else {
items.push({
"name": question.concat(" (cont.)"),
"value": parts[j],
"inline": false
});
}
}
}

var options = {
"method":"POST",
"payload": JSON.stringify({
"content":"Hello, World!",

"embeds":[{
"title":"War Times Form",
"fields":items,
"footer":{
"text":"***Please verify these are Correct***"
}
}]
})
};
Logger.log("[METHOD] onFormSubmit");
Logger.log(items);
Logger.log(options);
var response = UrlFetchApp.fetch(POST_URL, options);
Logger.log(response);
};

这就是日志记录在提交中的意思

[19-11-24 10:13:28:400 PST] {method=POST, payload={"content":"Hello, World!","embeds":[{"title":"War Times Form","fields":[{"name":"Post your clan name:","value":"fds","inline":false},{"name":"Post your name","value":"fds","inline":false},{"name":"Clan that you are declaring against:","value":"dfsa","inline":false},{"name":"Days and times your group is available was HQ fight (must be in EST):","value":"sdaf","inline":false}],"footer":{"text":"***Please verify these are Correct***"}}]}}

但是,我不断收到此错误:

Request failed for https://discordapp.com returned code 400. Truncated server response: {"message": "Cannot send an empty message", "code": 50006} (use muteHttpExceptions option to examine full response) at onSubmit(Code:54)

任何人都可以给我的任何帮助都会很棒。我已经尝试联系不和谐的支持,他们不会帮助它的 API/Dev

最佳答案

所以发现答案必须添加到通过请求发送的选项中。 Discord 显然改变了它并且没有告诉任何人你必须声明它

"contentType": "application/json",

关于javascript - Discord Webhook 消息无法发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59022027/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com