Build your own Discord bot using ChatGPT
[!IMPORTANT]
Major Update (2024/03):
- GPT-4 now supported for free
- Utilize OpenAI API can ensure smoother experiences, refer Optional: Configuring OpenAI API
.env.example
to .env
pip3 install -r requirements.txt
to install the required dependenciesGet 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
Open a terminal or command prompt
Navigate to the directory where you installed the ChatGPT Discord bot
python3 main.py
or python main.py
to run the botBuild the Docker image & run the Docker container with 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 botOPENAI_KEY
in .env
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
Go to https://www.bing.com/chat and log in
Open console with F12
Open Application
tab > Cookies
Copy the value for _U
from cookies and paste it into .env
under BING_COOKIE
Go to https://gemini.google.com/app and log in
Open console with F12
Open Application
tab > Cookies
Copy the value for __Secure-1PSID
from cookies and paste it into .env
under GOOGLE_PSID
system_prompt.txt
Go Discord setting turn developer mode
on
Right-click the channel you want to recieve the message, Copy ID
paste it into .env
under DISCORD_CHANNEL_ID
LOGGING
in the .env
to False中文設置教學
Commands
/chat [message]
Chat with ChatGPT/Gemini/draw [prompt]
Generate an image with Gemini/OpenAI/Bing/switchpersona [persona]
Switch between optional chatGPT jailbreaks
random
: Picks a random personastandard
: Standard chatGPT modedan
: DAN 13.5 (Latest Working ChatGPT Jailbreak prompt)Smart mode
: AIM (Always Intelligent and Machiavellian)Developer Mode
: software developer who specializes in the AI’s area/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
gpt-4
: GPT-4 modelGemini
: Google Gemini Model
Warning
Certain personas may generate vulgar or disturbing content. Use at your own risk.
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 —