MCPcopy Index your code
hub / github.com/Zero6992/chatGPT-discord-bot

github.com/Zero6992/chatGPT-discord-bot @v3.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.0.0 ↗ · + Follow
148 symbols 487 edges 16 files 44 documented · 30%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ChatGPT Discord Bot

Build your own Discord bot with multiple AI providers


[!IMPORTANT]

Major Refactor (2025/07): - 5 AI Providers: Free (g4f), OpenAI, Claude, Gemini, Grok - No Cookie Authentication: Removed unreliable cookie-based auth for free providers

Chat

image

Setup

Prerequisites

  • Python 3.9 or later
  • Rename the file .env.example to .env
  • Running pip3 install -r requirements.txt to install the required dependencies
  • Optional: API keys for premium providers (OpenAI, Claude, Gemini, Grok)

Step 1: Create a Discord bot

  1. Go to https://discord.com/developers/applications create an application
  2. Build a Discord bot under the application
  3. Get the token from bot setting

image 4. Store the token to .env under the DISCORD_BOT_TOKEN

image

  1. Turn MESSAGE CONTENT INTENT ON

image

  1. Invite your bot to your server via OAuth2 URL Generator

image

Step 2: Run the bot on the desktop

  1. Open a terminal or command prompt

  2. Navigate to the directory where you installed the ChatGPT Discord bot

3. Run python3 main.py or python main.py to run the bot

Step 2: Run the bot with Docker

  1. Build the Docker image & run the Docker container with docker compose up -d

  2. Inspect whether the bot works well docker logs -t chatgpt-discord-bot

### Stop the bot:

  • docker ps to see the list of running services
  • docker stop <BOT CONTAINER ID> to stop the running bot

Have a good chat!


Provider Configuration

Free Provider (unstable)

Outdated model, close to GPT-3.5 or GPT-4 capabilities

No configuration required

Premium Providers (Optional)

OpenAI

  1. Obtain your API key from https://platform.openai.com/api-keys
  2. Add to .env: OPENAI_KEY=your_api_key_here

Claude (Anthropic)

  1. Get API key from https://console.anthropic.com/
  2. Add to .env: CLAUDE_KEY=your_api_key_here

Gemini (Google)

  1. Get API key from https://ai.google.dev/
  2. Add to .env: GEMINI_KEY=your_api_key_here

Grok (xAI)

  1. Get API key from https://x.ai/api
  2. Add to .env: GROK_KEY=your_api_key_here

Use /provider command in Discord to switch between available providers

Image Generation

image

Image generation is now integrated with the provider system:

OpenAI DALL-E 3

  • Requires OpenAI API key
  • High-quality image generation
  • Use /draw [prompt] openai

Google Gemini

  • Requires Gemini API key
  • Free tier available
  • Use /draw [prompt] gemini

Fallback Options

  • If premium providers are unavailable, the bot will attempt to use free alternatives
  • Image generation capabilities vary by provider availability

Optional: Setup system prompt

  • A system prompt would be invoked when the bot is first started or reset
  • You can set it up by modifying the content in system_prompt.txt
  • All the text in the file will be fired as a prompt to the bot
  • Get the first message from ChatGPT in your discord channel!
  • Go Discord setting turn developer mode on

  • Right-click the channel you want to recieve the message, Copy ID

    ![channel-id](https://user-images.githubusercontent.com/89479282/207697217-e03357b3-3b3d-44d0-b880-163217ed4a49.PNG)
    
  • paste it into .env under DISCORD_CHANNEL_ID

Optional: Disable logging

  • Set the value of LOGGING in the .env to False

Commands

Core Commands

  • /chat [message] - Chat with the current AI provider
  • /provider - Switch between AI providers (Free, OpenAI, Claude, Gemini, Grok)
  • /draw [prompt] [model] - Generate images with specified provider
  • /reset - Clear conversation history
  • /help - Display all available commands

Persona Commands

  • /switchpersona [persona] - Switch AI personality (admin-only for jailbreaks)
  • standard - Standard helpful assistant
  • creative - More creative and imaginative responses
  • technical - Technical and precise responses
  • casual - Casual and friendly tone
  • jailbreak-v1 - BYPASS mode (admin only)
  • jailbreak-v2 - SAM mode (admin only)
  • jailbreak-v3 - Developer Mode Plus (admin only)

Bot Behavior

  • /private - Bot replies only visible to command user
  • /public - Bot replies visible to everyone (default)
  • /replyall - Bot responds to all messages in channel (toggle)

Security Features

Admin-Only Jailbreak Access

Jailbreak personas require admin privileges for enhanced security:

  1. Set ADMIN_USER_IDS in .env with comma-separated Discord user IDs
  2. Only admin users can access jailbreak personas
  3. Regular users see only safe personas in /switchpersona

Warning Jailbreak personas may generate content that bypasses normal AI safety measures. Admin access required.

Environment Security

  • No cookie-based authentication (removed for reliability)
  • Secure API key management via environment variables
  • Docker security hardening with non-root user
  • Read-only filesystem for container security

Core symbols most depended-on inside this repo

send_message
called by 15
src/aclient.py
is_jailbreak_persona
called by 13
src/personas.py
get_provider
called by 9
src/providers.py
set_current_provider
called by 6
src/providers.py
get_available_models
called by 5
src/providers.py
get_available_providers
called by 4
src/providers.py
send_split_message
called by 3
utils/message_utils.py
handle_response
called by 3
src/aclient.py

Shape

Method 102
Class 24
Function 22

Languages

Python100%

Modules by API surface

src/providers.py49 symbols
tests/test_providers.py20 symbols
src/bot.py17 symbols
auto_login/AutoLogin.py13 symbols
src/aclient.py12 symbols
auto_login/AutoLoginTest.py11 symbols
tests/test_personas.py9 symbols
tests/test_aclient.py4 symbols
src/personas.py4 symbols
src/log.py3 symbols
utils/message_utils.py2 symbols
src/art.py2 symbols

For agents

$ claude mcp add chatGPT-discord-bot \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact