chatGPT-discord-bot

ChatGPT Discord Bot

Build your own Discord bot with multiple AI providers


[!IMPORTANT]

Major Refactor (2025/07):

Chat

image

Setup

Prerequisites

  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

  5. Turn MESSAGE CONTENT INTENT ON

    image

  6. 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

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

  5. 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

Google Gemini

Fallback Options

Optional: Setup system prompt

Optional: Disable logging

Commands

Core Commands

Persona Commands

Bot Behavior

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