Critical prerequisites to install
- run
pip3 install -r requirements.txt
- Rename the file
.env.dev
to .env
- Recommended python version
3.10
Step 1: Create a Discord bot
- Go to https://discord.com/developers/applications create an application
- Build a Discord bot under the application
- Get the token from bot setting
- Store the token to
.env
under the DISCORD_BOT_TOKEN
- Turn MESSAGE CONTENT INTENT
ON
- Invite your bot to your server via OAuth2 URL Generator
Step 2: Official API authentication
Geanerate an OpenAI API key
- Go to https://beta.openai.com/account/api-keys
- Click Create new secret key
- Store the SECRET KEY to
.env
under the OPENAI_API_KEY
- You're all set for Step 3
Step 2: Website ChatGPT authentication - 2 approaches
- If you are using a Plus account, please modify
UNOFFICIAL_PAID
to "True"
in your .env
file
Email/Password authentication (Not supported for Google/Microsoft accounts)
- Create an account on https://chat.openai.com/chat
- Save your email into
.env
under OPENAI_EMAIL
- Save your password into
.env
under OPENAI_PASSWORD
- You're all set for Step 3
Session token authentication
- Go to https://chat.openai.com/chat log in
- Open console with
F12
- Open
Application
tab > Cookies
- Copy the value for
__Secure-next-auth.session-token
from cookies and paste it into .env
under SESSION_TOKEN
- You're all set for Step 3
Step 2: Google Bard authentication
- Go to https://bard.google.com/
- Open console with
F12
- Open
Application
tab > Cookies
- Copy the value for
__Secure-1PSID
from cookies and paste it into .env
under BARD_SESSION_ID
- You're all set for Step 3
Step 3: Run the bot on the desktop
- Open a terminal or command prompt
- Navigate to the directory where you installed the ChatGPT Discord bot
- Run
python3 main.py
to start the bot
Step 3: Run the bot with Docker
- Build the Docker image & Run the Docker container
docker compose up -d
- 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: Disable logging
- Set the value of
LOGGING
in the .env
to False
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
- Get the first message from ChatGPT in your discord channel!
- Right-click the channel you want to recieve the message,
Copy ID
- paste it into
.env
under DISCORD_CHANNEL_ID
Yeah, AI moves way too fast
Get the email that makes keeping up with AI easy and fun.