【发布时间】:2021-12-23 04:27:52
【问题描述】:
所以这是我的问题。
我正在尝试通过带有按钮的不和谐 webhook 发送消息,但它们不显示或有时只是给出错误代码。
错误代码基本上说我的 JSON stringicator 由于语法错误而无法运行,这很奇怪,因为如果我发送没有任何按钮组件的消息,它确实可以正常运行。
这是我的代码:
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));
【问题讨论】:
标签: javascript json discord webhooks