什么是 Discord Components V2?完整架构解析与迁移指南
全面深入了解 Discord 下一代消息排版系统——以模块化、可嵌套的容器架构彻底替代传统 Embed。
可视化搭建 Components V2
在 BuildCompose 中通过实时预览轻松创建嵌套容器、操作行 (Action Row) 与文本展示模块。
什么是 Components V2?它为何而生?
Components V2 是 Discord 消息系统多年来最大的一次架构升级。传统 Embed 被死死限制在固定结构内(标题、描述、内联字段、页脚),而 Components V2 引入了模块化的容器 Container (type 17) 与文本展示 Text Display (type 10),支持任意排版、自由嵌套以及强调色定制。
在调用原生 API 启用 Components V2 时,消息必须携带数值标志 32768 (MessageFlags.IsComponentsV2)。如果未包含该标志,Discord 将直接拒绝 Container 组件。
核心组件类型详解
Components V2 建立在多功能的基础积木之上:容器 Container (type 17) 可对多个子组件进行分组,并支持强调色侧边栏和剧透标签;文本展示 Text Display (type 10) 完整支持 markdown、标题与代码块;区块 Section (type 9) 可将文字与缩略图等辅助元素并排呈现;分割线 Separator (type 14) 用于规范整洁的区域划分。
JSON 载荷结构与代码示例
以下是 Components V2 基础容器在 JSON 中的组织方式,以及如何使用 discord.js v14 或 Discord REST API 进行发送的示例。
{
"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."
}
]
}
]
}// 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'
}
]
}
]
});如何从传统 Embed 迁移
迁移过程非常直观:旧版 Embed 的标题和描述可直接映射为容器内的文本展示组件;Embed 字段可映射为区块 Section 或纵向堆叠的文本组件。你可以借助 BuildCompose 的 Embed 转 Components V2 工具实现载荷的自动化转换。
使用我们免费的 Embed 转 Components V2 转换工具,直接粘贴现有 Embed JSON,即可秒级生成完全合规的 Components V2 代码。
常见问题
可以通过 Webhook 发送 Components V2 消息吗?
传统 Embed 会被弃用移除吗?
可以在 Components V2 容器中混用按钮组件吗?
相关指南
如何创建、配置与发送 Discord Webhook(分步实战指南)
学习如何生成 Discord Webhook、格式化 JSON 载荷、发送自定义 Embed 与机器人告警,并使用 BuildCompose 在线测试。
如何制作 Discord Embed:完整字段剖析与设计指南
手把手教你设计精美的 Discord Embed 消息。深入掌握作者字段、标题、描述、行内排版、侧边栏配色及 Markdown 排版黑科技。
Discord 字符与 Embed 限制速查表(2026 最新版)
针对 Discord API 各项指标的完整速查表:消息字符上限、Embed 尺寸、字段数量限制、Components V2、模态窗口及速率限制规范。