【问题标题】:I am trying to let my discord webhook send message with buttons我正在尝试让我的不和谐 webhook 使用按钮发送消息
【发布时间】: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


    【解决方案1】:

    您缺少一个 } 来关闭 params 对象。

    【讨论】:

    • 这确实消除了错误,但按钮仍然没有出现。
    猜你喜欢
    • 2020-11-20
    • 2023-02-15
    • 1970-01-01
    • 2019-07-11
    • 1970-01-01
    • 2021-01-19
    • 2021-06-01
    • 1970-01-01
    • 2020-12-26
    相关资源
    最近更新 更多