这就是我的问题。
我正在尝试通过带有按钮的不和谐网络钩子发送消息,但它们不显示或有时只给出错误代码。
错误代码基本上表明我的 JSON stringicicator 由于语法错误而无法运行,这很奇怪,因为如果我发送一条没有任何按钮组件的消息,它确实可以正常运行。
这是我的代码:
const request = new XMLHttpRequest();
request.open("POST", "/* the url of the bot */");
request.setRequestHeader('Content-type', 'application/json');
const params = {
"embeds": [
{
"title": "test",
"description": "test",
"color": 65474
}
],
"components": [
{
"type": 1,
"components": [
{
"type": 2,
"style": 5,
"label": "kaas",
"url": "/* url website */"
}
]
}
]
request.send(JSON.stringify(params));
您缺少用于关闭
}
对象的 params
。
要发送组件(例如按钮),您的应用程序需要拥有 Webhook
这基本上意味着你需要一个机器人