This repository hosts the code for a Discord bot that leverages the power of OpenAI's GPT-4 to provide advanced conversational AI capabilities. Designed to facilitate dynamic interactions, the bot enriches Discord servers with responsive and intelligent dialogues.
- The bot supports a dialogue mode with multiple users, distinguishes between users, and tracks the context of the dialogue
- It is possible to choose the bot's model
- Node.js (v16.16 or newer) / Docker
- Discord bot
- OpenAI API
- Create a new Discord bot https://discord.com/developers/applications
- [Your bot] -> Bot -> "Reset token" button for acquiring your secret token
- [Your bot] -> Bot -> Message content intent, Presence intent, Server members intent -> "On"
- https://discord.com/oauth2/authorize?client_id=[BOT_ID]&scope=bot&permissions=274878023680
- Top up your OpenAI API balance. Please note, this is not the balance of the main account. https://platform.openai.com/account/billing/overview
- Create a new API Key. For simplicity, I use Permissions=All. https://platform.openai.com/api-keys
- Select the model to be used. By default, it is gpt-4. https://platform.openai.com/docs/models/overview
-
Clone this repository:
git clone https://github.com/nokitakaze/GPT-4-Discord-Chatbot.git
-
Copy
.env.example
to.env
and fill in your Discord bot token and OpenAI API key:OPENAI_API_KEY=your_openai_api_key #GPT_MODEL=gpt-4 GPT_PROMPT="You are a helpful assistant. Respond briefly, but informatively." DISCORD_BOT_TOKEN=your_discord_bot_token
Optionally set GPT_MODEL to the desired model: https://platform.openai.com/docs/models/overview
-
Start it with docker
docker-compose up --build
Or manually
npm i npm start