npm / @chat-adapter/discord
@chat-adapter/discord
What changed in @chat-adapter/discord 4, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
4 breaking4 security27 new APIs and options10 behavior and defaults19 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@chat-adapter/discord 464 changes
Breaking changes 4
The interaction field is now typed as APIApplicationCommandInteraction for TypeScript consumers.
The user field is now typed as APIUser; user.avatar and user.global_name are string | null instead of optional strings.
Discord attachment downloads refuse private and internal addresses, including after DNS resolution and redirects, cap responses at 25 MB, and time out after 30 seconds.
Gateway mode ignores @everyone and @here pings by default; enable this option to restore the old behavior.
Security 4
Discord now uses parseIncoming() for incoming messages, parsing each message once and applying limits to avoid slow or unsafe markdown parsing. When a limit is hit, content is kept but formatted markdown structure is lost.
Callback tokens are consumed once.
External link metadata is marked as untrusted.
Adds custom webhook verification to the Discord adapter.
New APIs and options 27
Converters can override this method to check rewritten text before parsing.
Converters can override this method to clean up text when incoming parsing falls back.
Converters can override this limit; parsing falls back to verbatim text when input has more than 512 angle brackets.
Incoming parsing falls back to verbatim text when the resulting AST is deeper than 128 levels.
Converters can override this limit; parsing falls back to verbatim text when input has more than 128 closing brackets.
Converters can override this limit; parsing falls back to verbatim text when lines are nested more than 32 levels deep.
Converters can override this limit; parsing falls back to verbatim text when input has more than 2,048 emphasis markers.
Converters can override this limit; parsing falls back to verbatim text when a word contains more than 8 www. links.
Adds scaffolding for Discord bots through the
--connectoption.Adds Vercel Connect credential resolvers to the Discord adapter.
Adds an opt-in channel allowlist that treats non-bot Discord messages as directed to the bot without requiring a mention; configure it with respondToChannelIds or DISCORD_RESPOND_TO_CHANNEL_IDS.
Opt in to Discord Components v2 rendering for Chat SDK cards with DiscordContentFormat.ComponentsV2.
Forwarded gateway messages can opt in to responding to global mentions via the mention_everyone field.
Adds support for renaming native Discord thread channels.
The Discord adapter implements
rehydrateAttachment, rebuildingfetchDatafrom the serialized CDN URL so consumers can download inbound attachments after deserialization.Adds a Discord adapter callback for setting flags on ephemeral slash command responses.
Adapter internals are now protected rather than private, allowing consumers to subclass an adapter and override or extend behavior such as processUpdate.
Adds a disabled prop to Button() for Discord, allowing developers to mark buttons as disabled.
Adds Discord slash command support by dispatching application command interactions to chat.processSlashCommand(...) while sending an immediate deferred interaction ACK.
Adds Partials.Channel to the gateway client to support DMs.
Adds table markdown rendering, allowing developers to render markdown tables through the adapter.
Adds the CardLink element.
Cards now support inline Select components and Radio buttons.
Adds the LinkButton component.
Adds Serde support.
Adds support for modals, modal events, text inputs and selectors in the Discord adapter.
Adds Discord support through the Discord chat adapter.
Behavior and default changes 10
Failed channel or user lookups during forwarding are logged at warn instead of being silently dropped.
Forwarded reaction events now include channel_type, the resolved thread for thread reactions, and the reacting user for DM reactions, avoiding a second channel lookup on the webhook side.
AI tools are more tightly scoped.
Direct-message conversations are isolated.
Queued messages are more tightly scoped.
Slash commands and button interactions are handled in Discord gateway-only mode.
The adapter now declares chat as a full dependency rather than an optional dependency, so it is installed automatically.
Adapters have overhauled fallback-render behavior.
Markdown rendering is fully streaming, including for Slack, which has native streaming.
Values are now loaded automatically from environment variables.
Fixes and other changes 19
Every line in a Discord blockquote now receives the quote prefix, and quoted blank lines separate blocks, preventing later lines and blocks from falling out of the quote.
Forwards the Discord gateway packet as it arrived on the wire, preventing discord.js mutations from adding a member.user field Discord never sent.
Events for the same channel are forwarded in Gateway delivery order, preventing quick add-then-remove reactions from racing.
Discord reports true for real pings, role mentions, @everyone, or allowlisted channels, and leaves other cases undetermined so SDK text detection can still recognize literal @botname text.
Legacy Gateway mode falls back to channel_id for slash commands and button clicks in channels discord.js has not cached, such as a first DM.
Ephemeral follow-ups are preserved.
Edits, deletes, and reactions try the thread first and fall back to the parent channel when Discord reports the starter message as unknown. Deleting a text-channel thread's starter message also deletes the thread.
Restores attachment downloads across Discord inbound message paths.
Preserves content and attachments from forwarded Discord message snapshots.
Preserves Discord's angle-bracket syntax when rendering markdown so link previews can be suppressed.
Mention conversion no longer mangles email addresses, @handles inside URLs, or mentions inside code spans, and does not double-wrap already-formatted <@id> tokens.
Preserves surrounding text, email addresses, and word@word handles; avoids double-wrapping formatted mentions while still converting mentions after a period.
Renders bare URLs and autolinks as bare URLs instead of masked links, which Discord only renders inside embeds.
Expanded npm keywords for adapter and state packages to improve discoverability, adding chat-sdk, chatbot, ai-agent, ai-sdk, vercel, and platform-specific terms.
When Discord returns error code 160004 because a thread already exists for a message, the adapter reuses that thread instead of falling back to a standalone channel message.
Thread starter parsing now uses referenced_message content so thread roots preserve the original parent message text and metadata.
Fixes nested list rendering during Markdown-to-platform conversion so child items retain indentation and newline separation.
Fixes reaction events that were missing thread context.
Fixes the thread channel ID used for reactions and delete operations.