我正试图让我的discord网络挂钩用按钮发送消息



所以这是我的问题。

我试图通过一个有按钮的discord网络挂钩发送消息,但它们不会显示,有时只是给出一个错误代码。

错误代码基本上说,我的JSON字符串由于syntrax错误而无法运行,这很奇怪,因为如果我发送的消息没有任何按钮组件,它确实可以正常运行。

这是我的代码:

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对象的}

最新更新