Warning
According to OpenAI's latest announcement, using unofficial API may result in the ban of your account. Please assess the risks yourself
/chat [message]
Chat with ChatGPT!/private
ChatGPT switch to private mode/public
ChatGPT switch to public mode/replyall
ChatGPT switch between replyall mode and default mode/reset
Clear ChatGPT conversation history/chat-model
Switch different chat model- Modifying
CHAT_MODEL
field in the.env
file change the default model OFFICIAL
: GPT-3.5 modelUNOFFICIAL
: Website ChatGPT
- Modifying
-
public mode (default)
the bot directly reply on the channel -
private mode
the bot's reply can only be seen by the person who used the command -
replyall mode
the bot will reply to all messages in the channel without using slash commands (/chat
will also be unavailable)Warning The bot will easily be triggered in
replyall
mode, which could cause program failures
-
run
pip3 install -r requirements.txt
-
Rename the file
.env.dev
to.env
-
Recommended python version
3.10
-
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 theDISCORD_BOT_TOKEN
-
Turn MESSAGE CONTENT INTENT
ON
-
Invite your bot to your server via OAuth2 URL Generator
-
Click Create new secret key
-
Store the SECRET KEY to
.env
under theOPENAI_API_KEY
-
You're all set for Step 3
-
Create an account on https://chat.openai.com/chat
-
Save your email into
.env
underOPENAI_EMAIL
-
Save your password into
.env
underOPENAI_PASSWORD
-
You're all set for Step 3
-
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
underSESSION_TOKEN
-
You're all set for Step 3
-
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
-
Build the Docker image & Run the Docker container
docker compose up -d
-
Inspect whether the bot works well
docker logs -t chatgpt-discord-bot
docker ps
to see the list of running servicesdocker stop <BOT CONTAINER ID>
to stop the running bot
- Set the value of
LOGGING
in the.env
to False
-
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!