You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过Webhook从脚本发送Discord嵌入消息,组件按钮不显示

Discord Webhook按钮不显示的排查方案
  • 确认Webhook类型:普通服务器频道直接创建的Webhook不支持components交互组件,只有关联Discord机器人应用的应用程序Webhook才能使用按钮这类交互元素。如果当前是普通Webhook,需替换为应用程序Webhook。
  • 补全JSON结构:你提供的JSON示例缺少最外层的{,完整的请求体必须包裹在大括号内,正确格式如下:
{
  "embeds": [
    {
      "title": "A title",
      "description": "A description",
      "color": 16711680,
      "fields": [
        {
          "name": "first name",
          "value": "value",
          "inline": true
        },
        {
          "name": "second name",
          "value": "value",
          "inline": true
        },
        {
          "name": "third name",
          "value": "value",
          "inline": true
        }
      ],
      "footer": {
        "text": "Powered by xxx",
        "icon_url": "a url"
      }
    }
  ],
  "components": [
    {
      "type": 1,
      "components": [
        {
          "type": 2,
          "label": "Click me!",
          "style": 5,
          "url": "https://example.com"
        }
      ]
    }
  ]
}
  • 验证API版本:确保请求使用Discord API v10及以上版本,旧版本不支持components字段。比如curl请求路径需指定版本:https://discord.com/api/v10/webhooks/[webhook-id]/[webhook-token]
  • 检查按钮字段有效性:链接按钮的url必须是有效的HTTP/HTTPS链接,label不能为空且长度不超过80字符。
  • 规范请求发送方式:
    • App Script发送时,需设置Content-Type: application/json请求头,且用JSON.stringify()将请求体转为字符串。
    • curl发送时,需添加-H "Content-Type: application/json"参数,确保JSON内容格式正确(避免引号未转义问题)。

内容的提问来源于stack exchange,提问作者Lorenzo Pimps

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 06:35:58