Skip to main content

chat-adapter-discord

Discord adapter for chat-py. Python port of upstream packages/adapter-discord.

Targets Discord's HTTP Interactions path (signed webhooks) with REST fall-outs for post / edit / delete / reactions / typing.

Install

uv add chat-py chat-py-adapter-discord chat-py-adapter-state-memory

Auth / config

Config field Env var Notes
botToken DISCORD_BOT_TOKEN Required. Bot token from the Discord developer portal.
publicKey DISCORD_PUBLIC_KEY Required for signature verification.
applicationId DISCORD_APPLICATION_ID Required for slash-command + interaction routing.
mentionRoleIds — Optional; role IDs that should be treated as mentions.

Minimal example

from chat import Chat
from chat_adapter_discord import create_discord_adapter
from chat_adapter_state_memory import create_memory_state

bot = Chat(
    user_name="mybot",
    adapters={"discord": create_discord_adapter()},  # reads DISCORD_* env vars
    state=create_memory_state(),
)


@bot.on_slash_command("hello")
async def hello(thread, command):
    await thread.post(f"Hello {command.user_name}!")

Mount bot.handle_webhook("discord", body, headers) under /api/webhooks/discord. Incoming PING interactions are acknowledged automatically; MessageComponent and ApplicationCommand interactions dispatch into the chat handler chain.

Thread ID

Discord thread IDs: discord:{channelId}:{threadId or messageId}. is_dm(thread_id) short-circuits DM detection.

Features

  • Ed25519 signature verification (verify_discord_signature) via PyNaCl
  • REST post / edit / delete / reactions / typing (httpx async client)
  • Button / link / select-menu card translation (card_to_discord_payload)
  • Fallback text rendering (card_to_fallback_text) for components that exceed Discord's limits
  • Slash command context (DiscordSlashCommandContext, parse_slash_command) including deferred-response tracking

Parity notes

  • Button style constants match upstream (BUTTON_STYLE_PRIMARY = 1, etc.).
  • DISCORD_MAX_CONTENT_LENGTH mirrors upstream's 2000-char limit.
  • Markdown ↔ mdast conversion matches DiscordFormatConverter.

Test

uv run pytest packages/chat-adapter-discord

# Live
DISCORD_TOKEN=... uv run pytest packages/chat-integration-tests -k discord

Upstream

https://github.com/vercel/chat/tree/main/packages/adapter-discord

Metadata

Release files for chat-py-adapter-discord 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for chat-py-adapter-discord 0.1.0
File Interpreter ABI Platform Actions
chat_py_adapter_discord-0.1.0-py3-none-any.whl Python 3 none any Details for chat_py_adapter_discord-0.1.0-py3-none-any.whl

Release files / chat_py_adapter_discord-0.1.0-py3-none-any.whl

Download URL chat_py_adapter_discord-0.1.0-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb83b7b9feb37482d3fcab7fc2a697cd85be9287f3d54e02934382ee45af7d0a
BLAKE2b-256 checksum
How to use checksums
dfbf69e6cd1782b94ce1283c1d26a9b6377e39540f04c99a7bb90d537b597eca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.20 {"installer":{"name":"uv","version":"0.9.20","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for chat-py-adapter-discord 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page