需在 Discord 开发者门户开启 Server Members 与 Message Content 特权 intent,并用 bot 和 applications.commands 范围邀请;OPENAI_API_KEY 需为 API 计费密钥,ChatGPT 订阅不含 API 额度;文档索引、记忆、代码执行等为可选依赖,需另装 extras 并配置对应密钥。
GPTDiscord
Kav-KMIT活跃维护把 ChatGPT 式对话、AI 绘图、内容审核、自定义知识库和 YouTube 摘要整合进 Discord 的机器人,让社区频道直接变成可对话的 AI 助手。
A robust, all-in-one GPT interface for Discord. ChatGPT-style conversations, image generation, AI-moderation, custom indexes/knowledgebase, youtube summarizer, and more!
git clone https://github.com/Kav-K/GPTDiscord.git
cd GPTDiscord
python3.13 -m venv .venv
source .venv/bin/activate
python -m pip install .
cp sample.env .env
python gpt3discord.pyREADME 未说明显存或 GPU 要求;基础机器人不依赖 Torch、Transformers、LlamaIndex 或 LangChain,转录下载媒体需安装 FFmpeg。
在 Discord 里一站式使用 OpenAI 聊天、视觉、绘图、转录、审核与联网搜索的机器人
把 ChatGPT 式对话、AI 绘图、内容审核、自定义知识库和 YouTube 摘要整合进 Discord 的机器人,让社区频道直接变成可对话的 AI 助手。
核心能力
- 用 /gpt ask 与 /gpt converse 进行带视觉和推理模型的对话
- 用 /dalle draw 调用 GPT Image 生成图片并以附件发送
- 用 /web 选择 Parallel 免费摘录或 OpenAI 合成答案
- 支持按角色 ID 限制命令、按钮与消息访问
- 可选接入文档索引、Qdrant/Pinecone 记忆与 E2B 代码执行
容易踩的坑
- v13.2.6v13.2.6 — Available integration commands最新正式版2026-10-18 · 2026-10-18 18:00 UTC
Only available integration commands appear in Discord and /help.
- Omits index, code, internet, transcription, and translation commands when their corresponding service is not loaded, including the Translate context action.
- Keeps OpenAI internet chat without Google credentials. Google search and its provider choice require both Google settings.
- Shows /setup only in personal-key mode; users can still see their OpenAI commands before saving a personal key.
- Removes stale unavailable commands during the existing startup synchronization, scoped to ALLOWED_GUILDS.
- Builds isolated SDK command groups so configuration and provider-option filtering cannot alter another instance.
Validation: 985 full-install and 699 base-install tests passed, including real SDK command registration, configuration combinations, handler binding, stale-command removal, help, and personal-key startup. Ruff, dependency checks, package builds, and Twine passed.
Deployed 13.2.6 to
llm.kaveenk.com. All 38 installed checks and 26 installed module hashes passed. Discord REST confirmed 15 registered commands: configured integrations remain available, translation and personal-key setup are absent, and internet chat exposes only OpenAI without Google credentials. The service started cleanly; canonical configuration, Maintainer permissions, databases, conversations, saved indexes, and pickle data were preserved. - v13.2.5v13.2.5 — Image command cleanup2026-10-18 · 2026-10-18 15:44 UTC
查看更新说明
Removes obsolete image command paths and unused image-control state.
- Removes the redundant
/dalle draw_oldalias; use/dalle draw. - Removes unused optimizer/retry switches, view arguments, and the global image request cache.
- Keeps
/dalle optimize, context-menu Draw, Vary, Retry, Save, and image storage administration. Each image keeps its own request and source for controls; Save remains available after generation controls expire. - Updates command descriptions and the upgrade/validation guides.
Validation: 973 full-install and 687 base-install tests passed, including actual Pycord command registration, image/context actions, current personal keys, ownership, concurrency, moderation, source retention, and Save-only timeout. Ruff, dependency checks, package builds, and Twine passed.
Deployed 13.2.5 to
llm.kaveenk.com. All 33 installed cleanup checks and all 26 installed module hashes passed. The bot started cleanly; canonical configuration, Maintainer permissions, databases, conversations, saved indexes, and pickle data were preserved. - Removes the redundant
- v13.2.4v13.2.4 — Remove retired OpenAI options2026-10-18 · 2026-10-18 15:23 UTC
查看更新说明
Removes retired OpenAI options and simplifies the current API workflows.
- Removes completion-era best_of/mode/use_org settings, ignored request flags, dead DALL·E generation branches, unused aliases, and retired pricing entries.
- Rejects confirmed retired text models before sending core, agent, indexing, web, or key-validation requests. Current/custom deployments and models with future shutdown dates remain usable.
- Uses current GPT Image settings and autocomplete. Saved 256/512 dimensions resolve to 1024 without rewriting stored settings; explicit reset clears obsolete settings entries.
- Preserves current image edits, Vary/Retry/Save, prompt styles, project/organization routing, and supported Chat Completions APIs.
- Updates setup, hosted transcription, native vision, and feature-validation guides.
Validation: 973 full-install and 687 base-install tests passed. Ruff, dependency checks, package builds, Twine, and all 49 packaged Python modules were verified. Regression coverage includes request rejection before API calls, custom/current models, database-free standalone web validation, untouched legacy settings during startup, explicit-reset cleanup, current image options, and image controls.
Retirement scope was verified against OpenAI's deprecations on October 18, 2026. Chat Completions remains supported.
Deployed 13.2.4 to
llm.kaveenk.com. All 26 installed cleanup checks passed, including current/custom model support, rejection before requests, ignored obsolete settings, runtime-only image-size normalization, and current autocomplete. All 26 installed module hashes matched the reviewed source. Search, indexing, and code-agent construction passed with network access blocked. The bot started cleanly; canonical configuration, Maintainer permissions, databases, conversations, saved indexes, and pickle data were preserved. - v13.2.3v13.2.3 — Remove Wolfram Alpha2026-10-18 · 2026-10-18 10:55 UTC
查看更新说明
Removes Wolfram Alpha from internet chats, optional dependencies, configuration examples, and documentation.
- Removes the Wolfram tool, agent instructions, tool labels, and credential accessor.
- Updates Discord help, the README, the internet-chat setup guide, sample environment, and validation notes.
- Keeps OpenAI web search, optional Google search, and webpage crawling available.
Validation: 922 full-install tests and 638 base-install tests passed. Ruff, package builds, Twine, and dependency checks passed. The built package contains no Wolfram dependency or source references. The remaining 27 search-provider tests also passed with the Wolfram SDK uninstalled.
Deployed 13.2.3 to
llm.kaveenk.comin a fresh environment. The Wolfram SDK, dependency declaration, credential accessor, and search bindings are absent. Actual OpenAI and Google agent/tool construction passed with network access blocked; no paid provider calls were made. All 17 installed module hashes matched the reviewed source. Startup was healthy, and canonical configuration, Maintainer permissions, databases, conversations, saved indexes, and pickle state were preserved. - v13.2.2GPTDiscord v13.2.2 — E2B code chat2026-10-18 · 2026-10-18 05:06 UTC
查看更新说明
Restores E2B code-chat execution, file handling, and cleanup with the current SDK.
- Shell and package commands return exit code, stdout, and stderr when they fail, allowing the agent to diagnose and correct them.
- All message attachments are uploaded with their exact sandbox paths. Python state and installed packages persist throughout the session.
- Generated CSVs and rich plot results can be downloaded through Download Artifacts. Downloads stream within the server's file-size limit, and ended-session controls give clear guidance.
- Code chats announce readiness after sandbox/agent registration; their opening message explains when to wait.
- Failed or canceled startup and graceful shutdown close active and late-created sandboxes. Close is idempotent, and SDK requests have explicit deadlines.
- OpenAI Responses use bounded output and disable provider storage while retaining local conversation history.
Install
pip install '.[code]', configureE2B_API_KEYalongside OpenAI access, and restart the bot. Use/code chat, wait for its ready message, and typeendto close it. Operators should allow a 120-second graceful service stop window.Validation: 922 full-install tests and 638 base-install tests passed, including 29 focused code tests. Ruff, dependency checks, package builds, and Twine checks pass. A real live workflow verified numeric execution, persistent Python state, aggregation of two uploaded CSVs, CSV and rich PNG downloads through the actual button callback, Python package installation/import, nonzero command diagnostics, system package installation, duplicate suppression, End and cleanup. It used nine bounded Responses requests, one sandbox capped at 300 seconds, and eight executions/commands. All owned resources were removed. Human authorship and interaction acknowledgements are adapted by the diagnostic runner; execution tools and results are real.
The same 11 live checks also passed from the installed 13.2.2 package on
llm.kaveenk.com, using 9 bounded Responses requests, one 300-second sandbox, and 8 executions/commands. Installed modules matched the merged source; the service stayed healthy, all owned resources were cleaned up, and canonical databases, saved indexes, conversations, permissions, and configuration remained unchanged during testing.Cursor Bugbot reached its usage limit; independent reviews were completed and their findings were addressed.
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
GPTDiscord
OpenAI chat, vision, image generation, transcription, moderation, and web search in Discord. Python 3.11–3.13 is supported.
Current API support
/gpt askand/gpt converseuse current Chat Completions models, including vision and reasoning models. Defaults and model limits are centralized; incompatible sampling options are omitted for reasoning models./weboffers Parallel source excerpts without an API key, or OpenAI synthesized answers with visible source links. Automatic selection preserves configured OpenAI credentials and model settings; otherwise it uses Parallel. Selectprovider: parallelfor a free source lookup orprovider: openaifor a paid answer./dalle drawkeeps the familiar command name and generates images with the current GPT Image API. Image bytes are sent as Discord attachments. Retired DALL·E endpoints are no longer used.- Transcription and moderation use current OpenAI APIs. Long conversations, per-user keys, server roles, prompt optimization, and saved conversations remain available.
- Document indexing, internet chat, Qdrant/Pinecone memory, Replicate, and E2B code execution are optional integrations with separate dependencies.
The default chat model is gpt-6.1-sol, the low-cost helper model is gpt-6-luna, and image generation defaults to gpt-image-2.5-flare. Availability depends on your OpenAI project. Override models using the environment settings below. Model names and prices change; consult the OpenAI model catalog and pricing.
Run from source
git clone https://github.com/Kav-K/GPTDiscord.git
cd GPTDiscord
python3.13 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install .
cp sample.env .env
# Edit .env with your credentials and Discord server ID.
python gpt3discord.py
Install FFmpeg with your operating system's package manager to transcribe downloaded media. The basic bot does not require Torch, Transformers, LlamaIndex, or LangChain.
The same code installs as the gpt3discord console command. Prompt files and conversation openers ship in the wheel; you can run the installed bot outside the source directory.
Required configuration
| Setting | Purpose |
|---|---|
OPENAI_API_KEY | OpenAI project API key. OPENAI_TOKEN remains a supported alias. ChatGPT subscriptions do not include API billing. |
DISCORD_TOKEN | Bot token from the Discord Developer Portal. |
ALLOWED_GUILDS | Comma-separated Discord server IDs where commands are registered. |
DATA_DIR | Writable directory for local data and usage estimates. Defaults to the current directory. |
Enable the Server Members and Message Content privileged gateway intents for the Discord application; invite the bot with the bot and applications.commands OAuth scopes and permissions to read/send messages, attach files, embed links, and create/use threads. Review the role controls in sample.env before inviting it to a public server. Debug guild/channel IDs are optional.
Startup synchronizes commands only in ALLOWED_GUILDS, preserving global registrations and commands in other servers.
Keep credentials in an untracked .env or your hosting platform's secret store. GitHub credentials are unnecessary to run the basic bot or its tests. No passwords are required.
Role restrictions
Set BOT_ACCESS_ROLE_IDS to a comma-separated list of Discord role IDs to restrict bot access. The restriction applies to commands, buttons, modal submissions, autocomplete, and messages processed by the bot. Members must hold one of those exact roles; administrator status and matching role names do not bypass it. Direct messages are denied while this restriction is enabled. Leave the setting unset to retain the existing per-feature role controls.
Per-feature settings such as GPT_ROLES, ADMIN_ROLES, and SEARCH_ROLES accept role IDs or case-insensitive names. Their checks still apply alongside the access restriction. To allow a restricted role to use every feature, put its ID in each applicable role setting as well. Role IDs continue to work when Discord's role-name cache is unavailable and remain valid after a role is renamed. Restart the bot after changing these settings.
Conversation delivery recovery
Discord can provide working application commands and REST access while omitting a correctly installed server from the bot's gateway connection. Use the conversation smoke guide to distinguish gateway delivery from REST-backed checks.
For those servers, opt in with CONVERSATION_RECOVERY_GUILD_IDS, a comma-separated subset of ALLOWED_GUILDS. Recovery also requires BOT_ACCESS_ROLE_IDS. It checks current member role IDs through REST and polls only explicitly registered conversations: bot-owned public/private threads, index/search/code chat threads, and full-channel conversations deliberately started with /gpt converse use_threads:false. Administrator status and matching role names do not bypass the configured role IDs. Free mentions, general moderation, and message edits still require Gateway events.
Recovery polls immediately on startup, then at a nominal three-second interval. An existing thread's first successful enrollment uses the latest message ID returned by Discord as its baseline. Messages at or before that baseline are skipped, so a post sent after startup but before enrollment may be skipped. Saved cursors keep their position, and new conversations start from their creation IDs. Polling does not recover undelivered edits; send corrections as new messages. Durable cursors in DATA_DIR/conversation_recovery.sqlite prevent the same incoming turn from being dispatched again by polling, gateway overlap, or restart. A failure after claiming a turn can leave it unanswered; this provides at-most-once ingress and does not guarantee exactly-once provider billing. See the guide for scope and verification details.
Recovery serves up to four sessions concurrently, keeping each session's messages in order. Full-channel sessions start at the latest message when enrolled, and starting a new session resets that baseline. Opening prompts, Retry, and End share the conversation lock and busy checks. Retry replaces the latest answer in memory as well as on Discord; older turns cannot replace newer conversation history. Private conversations require threads and explicitly add their owner. Conversations backed by Qdrant or Pinecone require corrections as new messages instead of Retry or message edits.
Model and project settings
OPENAI_MODEL=gpt-6.1-sol
OPENAI_IMAGE_MODEL=gpt-image-2.5-flare
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
OPENAI_MODERATION_MODEL=omni-moderation-latest
OPENAI_TRANSCRIPTION_MODEL=gpt-4o-mini-transcribe
# OPENAI_PROJECT=proj_...
# OPENAI_ORGANIZATION=org_...
# OPENAI_BASE_URL=https://api.openai.com/v1
Automatic model selection follows OPENAI_MODEL, or gpt-6.1-sol when it is unset. A supported model saved through /system settings takes precedence across restarts; existing supported saved choices are preserved. Resetting all system settings or turning low-usage mode off resumes automatic selection.
OPENAI_BASE_URL supports compatible providers. Only configure endpoints you trust with your API credentials. Core chat keeps the Chat Completions response shape; the OpenAI option in /web requires a provider implementing Responses and native web search.
Web search providers
Use /web question:<question> provider:parallel to get up to five titled source
excerpts and clickable links from Parallel Search MCP.
Search uses Fast mode without a Parallel account, API key, or model request.
These are source excerpts, not a synthesized answer. Free service limits can apply.
With no provider option, automatic selection retains OpenAI when an applicable
host key (OPENAI_API_KEY or OPENAI_TOKEN), saved personal key, or
OPENAI_MODEL is configured. Otherwise it uses Parallel. Personal-key mode
never borrows the host key. An explicit model selects OpenAI; omit it for
Parallel. OpenAI answers require a key with Responses/web-search access and incur
model and hosted-search charges. A failed provider request does not switch providers.
Set WEB_SEARCH_PROVIDER=parallel or openai to choose the bot's default;
the command's provider/model options override that selection. The default setting
is auto. Set WEB_SEARCH_PROVIDER=disabled to block both providers, including
explicit command selections. Existing SEARCH_ROLES and bot-access restrictions
apply to either provider. Parallel is included in the base install; /internet
conversations continue to use their existing OpenAI or Google provider.
Optional integrations
Install the extras you use and configure their keys. Missing configured dependencies produce an actionable startup error. Commands for unavailable optional services are not registered, and /help shows only registered commands. Existing interaction handlers retain setup guidance for stale interactions.
| Feature | Install | Configuration |
|---|---|---|
| Document Q&A / indexes | pip install '.[index]' | ENABLE_INDEXING=true and OpenAI access |
| Internet chat / Google search | pip install '.[search]' | OpenAI access for chat; Google keys only for provider: google or /internet search |
| Pinecone memory | pip install '.[pinecone]' | PINECONE_TOKEN, PINECONE_REGION (default us-east-1) |
| Qdrant memory | pip install '.[qdrant]' | QDRANT_PATH for persistent local storage, or QDRANT_URL and optional QDRANT_API_KEY |
| E2B code execution | pip install '.[code]' | E2B_API_KEY |
| DeepL translation | Included in the base install | DEEPL_TOKEN |
| Replicate fallback vision | pip install '.[replicate]' | REPLICATE_API_KEY |
| All integrations | pip install '.[full]' | Only configure the integrations you intend to enable |
Configure either Qdrant or Pinecone memory, never both. Leave both unset to keep local conversation summaries. See the memory guide for collection and migration details.
/internet chat defaults to OpenAI web search using your existing OpenAI key, with clickable citations, conversation memory, and optional page crawling. The search integration loads automatically when its dependencies are installed; Google credentials are not required for OpenAI chat. The provider: google choice and /internet search appear only when both GOOGLE_SEARCH_API_KEY and GOOGLE_SEARCH_ENGINE_ID are configured. search_scope caps OpenAI web tool calls per model response or Google result links per search; it does not guarantee a number of sources. OpenAI hosted-search fees are separate from model token usage. /web remains available without optional dependencies.
/setup is registered only when USER_INPUT_API_KEYS=true. Individual users do not need to save a key before their OpenAI commands appear. After changing integration settings or installed dependencies, restart the bot: startup reloads configuration and synchronizes the available commands in ALLOWED_GUILDS, removing previously registered commands that are now unavailable.
When USER_INPUT_API_KEYS=true, optional index/search/code sessions accept messages from their creator only, so other thread participants cannot spend that person's API credits. Changing or deleting the saved key blocks further work in an existing session; end it and start a new one with the current key.
The index extra includes GitHub and YouTube readers. GitHub repositories use GITHUB_TOKEN and their default branch. YouTube videos need an accessible English transcript. Public Google Docs links use text export; upload an exported document for private Docs. Uploaded images use native vision, while supported audio/video uploads use speech transcription before indexing. These media operations incur OpenAI charges; video frames are not indexed. Legacy Office files, SVG, and PSD require conversion first.
/index add selects the saved document for /index query and your next /index chat. Use /index chat user_index:<name> or /index load to choose another saved index. After a restart, chat defaults to your most recently saved index. The opening message identifies the connected source. Adding or loading documents inside your own chat connects them to that chat while preserving its existing documents and history. Empty chats ask you to connect a document before answering. PDF links must contain extractable text and be 25 MiB or smaller; scanned pages need OCR first.
LlamaIndex currently requires OpenAI SDK 2.x. Installing its extra selects the current compatible SDK; the core also supports SDK 3.x. Requirements files delegate to pyproject.toml so dependencies have one source of truth.
Docker
Build this checkout with Docker Compose:
cp sample.env .env
# Edit .env, then:
docker compose up --build -d
docker compose logs -f
The container runs as UID/GID 10001, includes FFmpeg, and persists data in a named volume. Existing bind-mounted data must be writable by this user. To include optional integrations, set the FULL build argument to true in Compose. The existing /opt/gpt3discord/etc/environment mount location remains supported.
CI builds both base and full images on pull requests. Registry publication is limited to releases or an explicit manual workflow and uses GitHub Container Registry authentication provided by Actions. PyPI publication uses PYPI_TOKEN when configured, with trusted publishing as the fallback when it is unset.
Upgrade from v12
- Back up
.env, SQLite databases, pickles, local indexes, and stored vectors. Upgrade in a fresh Python 3.11–3.13 virtual environment; do not reuse the old pinned package set. - Install the core or the extras you use. Set
ENABLE_INDEXING=trueto enable document indexing. The basic bot and/webneed no legacy search libraries. - Keep
OPENAI_TOKENor rename it toOPENAI_API_KEY. Review model overrides and role settings. Retired preview models saved in bot settings are migrated to current defaults. - Set
DATA_DIRand, if previously used,SHARE_DIRto your existing writable data locations. Custom prompt/openers files can still be supplied throughSHARE_DIR. - Rebuild document indexes when changing embedding models. Ada and embedding-3 vectors occupy different vector spaces even at the same dimension. New Pinecone embedding namespaces keep these separate; selecting
text-embedding-ada-002retains the legacy namespace. Re-ingest historical text to use the newer embeddings. Legacy Pinecone numeric conversation IDs above2**53must also be re-ingested; new records store exact string IDs. Old local LlamaIndex storage may also need re-ingestion after the library upgrade. - Rebuild Docker images and check file ownership for existing volumes. Automatic deployment to the old hardcoded SSH host and formatter force-pushes have been removed. Configure deployment separately for your own host.
Conversation sharing now uses an owner-only private TXT download instead of the obsolete ShareGPT service. Retired best_of, mode, and use_org settings are no longer loaded or written. Old entries are ignored and removed when system settings are reset; conversations, indexes, and user API keys are preserved. API retirement decisions follow OpenAI's API deprecations, reviewed on October 18, 2026.
Use /dalle draw to generate images and /dalle optimize to refine a prompt before drawing. The redundant /dalle draw_old alias has been removed. The message context menu also offers Draw.
Generated images offer per-image Vary controls using the current GPT Image edit API. This creates a source-guided variation preserving the subject and style; it differs from retired DALL·E random variation sampling. Retry retains the source image. Save remains available after generation controls expire. There is no general upload/edit slash command.
Image sizes are auto, square 1024x1024, landscape 1536x1024, or portrait 1024x1536. Saved 256x256 and 512x512 settings migrate to 1024x1024.
The local usage total is an estimate, not an OpenAI invoice. Known text models use separate input, cached-input, and output token rates. Unknown models are logged and excluded rather than billed at an unrelated legacy rate. Image/audio/tool fees are not included in this token estimate; use your provider's usage dashboard for billing.
Development and verification
See the original-feature validation matrix for live and offline coverage, replaced features, and configuration limits.
python -m pip install -e '.[dev]'
python -m pip check
python -m ruff check .
python -m pytest -q -m 'not integration'
python -m build
python -m twine check dist/*
Normal tests mock OpenAI requests and require no credentials. Qdrant tests use real temporary local storage. At runtime, tiktoken downloads its vocabulary on first token counting; a populated TIKTOKEN_CACHE_DIR avoids that download. If network or cache access fails, core chat, document Q&A, tree/router composition, crawling, and optional chat memory use conservative UTF-8 byte counts until restart. API-reported usage still determines usage accounting. Paid integration tests only run when explicitly enabled:
RUN_LIVE_OPENAI_TESTS=1 python -m pytest -m integration
For broader live checks with OPENAI_API_KEY already in the environment, run python -m tests.live_openai_smoke --run-live from a fresh process. This makes at most one request per feature, caps text output at 512 tokens, and generates one low-quality image. Use --features chat,web to select checks; image/audio/tool charges still apply. The JSON report contains response shapes and usage counters, without credentials or generated content.
CI checks Python 3.11–3.13, Windows/macOS smoke tests, optional integration installs/imports, and wheel contents outside the checkout. Publishing and deployment credentials are not needed for pull requests.
Historical feature guides remain in detailed_guides; their screenshots and setup details may describe older releases. Use this README and sample.env for current installation and API configuration. Contributions are welcome under the MIT license.