⭐️ If this repo helps you, a star is the biggest support for me and also helps you stay up-to-date
Warning
OpenAI added Cloudflare protections to their API in 2022-12-12, there are some differences in using it on server and desktop environment
/chat [message]
Chat with ChatGPT!/private
ChatGPT switch to private mode/public
ChatGPT switch to public mode/reset
ChatGPT conversation history will be erased
-
public mode (default)
the bot directly reply on the channel -
private mode
the bot's reply can only be seen by who use the command
-
pip install -r requirements.txt
-
Run
playwright install
orpython -m playwright install
-
Go to https://discord.com/developers/applications create an application
-
Build a Discord bot under the application
-
Get the token from bot setting
-
Change the file name of
config.dev.json
toconfig.json
-
Store the token to
config.json
under thediscord_bot_token
-
Turn MESSAGE CONTENT INTENT
ON
-
Invite your bot to your server via OAuth2 URL Generator
You do not need to fill out
session_token
inconfig.json
- 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
- Wait for the Cloudflare checks to pass
- Reload if show
ChatGPT is at capacity right now
- Log into OpenAI via the open browser (Your account)
- It should automatically redirect you to https://chat.openai.com/chat after logging in. If it doesn't, go to this link manually after logging in.
- The window should close automatically
You must fill the session token in
config.json
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 intoconfig.json
undersession_token
I use
Xvfb
to emulate a desktop environment. It should automatically get the cf_clearance given no captcha
-
Build the Docker image
docker build -t chatgpt-discord-bot .
-
Run the Docker container
docker run -d chatgpt-discord-bot
docker ps
to see the list of running servicesdocker stop <BOT CONTAINER ID>
to stop the running bot
-
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!