Build Compose - Free Discord Message Builder
构建器与界面 6 min read Updated: 2026-11-10

什么是 Discord Components V2?完整架构解析与迁移指南

全面深入了解 Discord 下一代消息排版系统——以模块化、可嵌套的容器架构彻底替代传统 Embed。

#Components V2 #Discord API #UI Layouts #Containers

可视化搭建 Components V2

在 BuildCompose 中通过实时预览轻松创建嵌套容器、操作行 (Action Row) 与文本展示模块。

打开 Components V2 构建器
1

什么是 Components V2?它为何而生?

Components V2 是 Discord 消息系统多年来最大的一次架构升级。传统 Embed 被死死限制在固定结构内(标题、描述、内联字段、页脚),而 Components V2 引入了模块化的容器 Container (type 17) 与文本展示 Text Display (type 10),支持任意排版、自由嵌套以及强调色定制。

进阶提示

在调用原生 API 启用 Components V2 时,消息必须携带数值标志 32768 (MessageFlags.IsComponentsV2)。如果未包含该标志,Discord 将直接拒绝 Container 组件。

2

核心组件类型详解

Components V2 建立在多功能的基础积木之上:容器 Container (type 17) 可对多个子组件进行分组,并支持强调色侧边栏和剧透标签;文本展示 Text Display (type 10) 完整支持 markdown、标题与代码块;区块 Section (type 9) 可将文字与缩略图等辅助元素并排呈现;分割线 Separator (type 14) 用于规范整洁的区域划分。

3

JSON 载荷结构与代码示例

以下是 Components V2 基础容器在 JSON 中的组织方式,以及如何使用 discord.js v14 或 Discord REST API 进行发送的示例。

Discord Components V2 Payload (JSON)
{
  "flags": 32768,
  "components": [
    {
      "type": 17,
      "accent_color": 5793266,
      "spoiler": false,
      "components": [
        {
          "type": 10,
          "content": "### Welcome to our Community Server!\nEnjoy modern rich UI powered by Discord Components V2."
        }
      ]
    }
  ]
}
discord.js (v14+ / REST)
// Send a message with Components V2 container using Discord REST API
await channel.send({
  flags: 32768, // MessageFlags.IsComponentsV2
  components: [
    {
      type: 17, // ComponentType.Container
      accent_color: 0x5865f2,
      components: [
        {
          type: 10, // ComponentType.TextDisplay
          content: '### Modern Components V2 Layout'
        }
      ]
    }
  ]
});
4

如何从传统 Embed 迁移

迁移过程非常直观:旧版 Embed 的标题和描述可直接映射为容器内的文本展示组件;Embed 字段可映射为区块 Section 或纵向堆叠的文本组件。你可以借助 BuildCompose 的 Embed 转 Components V2 工具实现载荷的自动化转换。

快捷迁移工具

使用我们免费的 Embed 转 Components V2 转换工具,直接粘贴现有 Embed JSON,即可秒级生成完全合规的 Components V2 代码。

常见问题

相关指南