我正在尝试让我的 Discord Webhook 使用按钮发送消息

问题描述 投票:0回答:2

这就是我的问题。

我正在尝试通过带有按钮的不和谐网络钩子发送消息,但它们不显示或有时只给出错误代码。

错误代码基本上表明我的 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));
javascript json discord webhooks
2个回答
0
投票

您缺少用于关闭

}
对象的
params


0
投票

您的应用程序需要拥有 webhook

要发送组件(例如按钮),您的应用程序需要拥有 Webhook

拥有 webhook 意味着什么?

这基本上意味着你需要一个机器人

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.