Vercel News

Chat SDK adds Discord Components V2 support

6.7内容质量

TL;DR · AI 摘要

Chat SDK adds Discord Components V2 support - Vercel You can now send Discord bot messages with Components V2 , an opt-i...

核心要点

  • 主题聚焦:Chat SDK adds Discord Components V2 support
  • 来源:Vercel News,建议结合原文判断细节。
  • AI 分析暂不可用,本条为保底评分与摘要。
#AI#产品
打开原文

Chat SDK adds Discord Components V2 support - Vercel

You can now send Discord bot messages with Components V2 , an opt-in layout system that treats text, images, files, and buttons as flexible components you can arrange in any order.

Set the adapter's contentFormat option to ComponentsV2 and cards render with native containers, sections, media galleries, separators, buttons, and string selects. Embeds remain the default, so existing bots work unchanged.

lib/bot.tsx

code
1
import
{
Actions
,
Button
,
Card
,
CardText
,
Image
,
LinkButton
,
Section
}
from
"chat"
;
2
import
{
createDiscordAdapter
,
DiscordContentFormat
}
from
"@chat-adapter/discord"
;
3
4
const
discord
=
createDiscordAdapter
(
{
5
contentFormat
:
DiscordContentFormat
.
ComponentsV2
,
6
}
)
;
7
8
await
thread
.
post
(
9
<
Card
title
=
"
Deployment ready
"
subtitle
=
"
Production build completed
"
>
10
<
Section
>
11
<
CardText
>
12
**Version 2.4.0** is ready to promote.
13
14
Review the release notes, then choose an action below.
15
</
CardText
>
16
<
Image
url
=
"
https://example.com/deploy-preview.png
"
alt
=
"
Preview
"
/>
17
</
Section
>
18
19
<
Actions
>
20
<
Button
id
=
"
promote
"
style
=
"
primary
"
>
Promote
</
Button
>
21
<
Button
id
=
"
rollback
"
style
=
"
danger
"
>
Roll back
</
Button
>
22
<
LinkButton
url
=
"
https://example.com/deployments/123
"
>
View deployment
</
LinkButton
>
23
</
Actions
>
24
</
Card
>
25
)
;

A card with sections, markdown, images, and actions rendered as Discord Components V2.

Individual sections can carry their own actions, markdown renders correctly inside components, and the adapter enforces Discord's platform limits for you, including the 40-component cap per message.

This release also includes several other Discord adapter improvements:

  • Rename threads: A new setThreadTitle() method renames native Discord thread channels. Your bot needs the Manage Threads permission to use it.
  • Ignore global pings: Bots running in gateway mode no longer treat @everyone and @here announcements as mentions. A new respondToGlobalMentions config option (default false ) lets you opt back in. Direct mentions, role mentions, and replies to the bot are unaffected.
  • Precise mention detection: Mentions of similarly named users no longer trigger false matches. A message with @bot-dev no longer counts as a bot tag.

Read the documentation to get started or browse the adapter directory .

Special thanks to community contributors DeanMauro , onmax , FarazPatankar , and sivchari for laying the groundwork for these improvements.