Skip to content

Integrate ChatGPT into your own discord bot for story teller

License

Notifications You must be signed in to change notification settings

chun92/chatGPT-discord-bot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chatGPT-discord-bot

This is a project that provides you to build your own Discord bot using ChatGPT

⭐️ A star would be highly appreciated

Features

  • /chat [message] Chat with ChatGPT!
  • /private ChatGPT switch to private mode
  • /public ChatGPT switch to public mode
  • /reset ChatGPT conversation history will be erased

Chat

image

Mode

  • public mode (default) the bot directly reply on the channel

    image

  • private mode the bot's reply can only be seen by who use the command

    image

Setup

Install

pip install -r requirements.txt

dependencies: Reverse Engineered ChatGPT by OpenAI here and discord.py

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 config.json 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: Token authentication

Go to https://chat.openai.com/chat log in

  1. Open console with F12

  2. Open Application tab > Cookies

    image

  3. Copy the value for __Secure-next-auth.session-token from cookies and paste it into config.json under session_token

  4. Find your cf_clearance from cookies and paste it into config.json under cf_clearance

    Warning

    Cloudflare cf_clearance have a 2-hour expiration, so you will need to manually log in and retrieve it periodically

  5. Get your user-agent from network and paste it into config.json under user-agent

    Network > Headers > Request Headers > User-Agent

    image

  6. It should be look like this

    image

Step 3: Run the bot

  1. Open a terminal or command prompt
  2. Navigate to the directory where you installed the ChatGPT Discord bot
  3. Run python3 main.py to start the bot

Step 3: Run the bot with docker

  1. Build the Docker image docker build -t chatgpt-discord-bot --platform linux/amd64 .

  2. Run the Docker container docker run --platform linux/amd64 -d 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

Optional: Setup starting prompt

  • A starting prompt would be invoked when the bot is first started or reset
  • You can set it up by modifying the content in starting-prompt.txt
  • All the text in the file will be fired as a prompt to the bot

Have A Good Chat !

About

Integrate ChatGPT into your own discord bot for story teller

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.4%
  • Dockerfile 1.6%