chatGPT-discord-bot

ChatGPT Discord Bot

Build your own Discord bot using ChatGPT


[!IMPORTANT]

Major Update (2024/03):

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!


Optional: Configuring OpenAI API

  1. Obtain your API key by visiting https://platform.openai.com/api-keys
  2. Paste the API key under OPENAI_KEY in .env
  3. Set OPENAI_ENABLED to True in .env

[!NOTE] GPT-4 API is subject to certain restrictions.

Details https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4

Image Generation

image

Microsoft Bing Image Generation

  1. Go to https://www.bing.com/chat and log in

  2. Open console with F12

  3. Open Application tab > Cookies

  4. Copy the value for _U from cookies and paste it into .env under BING_COOKIE

Google Gemini Image Generation

  1. Go to https://gemini.google.com/app and log in

  2. Open console with F12

  3. Open Application tab > Cookies

  4. Copy the value for __Secure-1PSID from cookies and paste it into .env under GOOGLE_PSID

Optional: Setup system prompt

Optional: Disable logging


中文設置教學

Commands

Switch Persona

Warning

Certain personas may generate vulgar or disturbing content. Use at your own risk.

image

Mode