![](https://onlinelearningportal.website/wp-content/uploads/2023/02/download.jpeg)
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](https://user-images.githubusercontent.com/89479282/206497774-47d960cd-1aeb-4fba-9af5-1f9d6ff41f00.gif)
Mode
public mode (default)
the bot directly reply on the channelprivate mode
the bot’s reply can only be seen by the person who used the command
Setup
Install
pip install -r requirements.txt
- Rename the file
config.dev.json
toconfig.json
Step 1: Create a Discord bot
- Go to https://discord.com/developers/applications and create an application
- Build a Discord bot under the application
- Get the token from the bot setting
![](https://onlinelearningportal.website/wp-content/uploads/2023/02/205949161-4b508c6d-19a7-49b6-b8ed-7525ddbef430.png)
- Store the token to config.json under the discord_bot_token
![](https://onlinelearningportal.website/wp-content/uploads/2023/02/207357762-94234aa7-aa55-4504-8dfd-9c68ae23a826.png)
- Turn MESSAGE CONTENT INTENT ON
![](https://onlinelearningportal.website/wp-content/uploads/2023/02/205949323-4354bd7d-9bb9-4f4b-a87e-deb9933a89b5-1024x147.png)
- Invite your bot to your server via OAuth2 URL Generator
![](https://onlinelearningportal.website/wp-content/uploads/2023/02/205949600-0c7ddb40-7e82-47a0-b59a-b089f929d177.png)
Step 2: Geanerate a OpenAI API key
- Go to https://beta.openai.com/account/api-keys
- Click Create new secret key
![](https://onlinelearningportal.website/wp-content/uploads/2023/02/207970699-2e0cb671-8636-4e27-b1f3-b75d6db9b57e-1024x551.png)
- Store the SECRET KEY to
config.json
under theopenAI_key
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 servicesdocker stop <BOT CONTAINER ID>
to stop the running bot
Have a good chat!
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 receive the message, Copy ID
![](https://onlinelearningportal.website/wp-content/uploads/2023/02/207697217-e03357b3-3b3d-44d0-b880-163217ed4a49.png)
- paste it into
config.json
underdiscord_channel_id