This repo is a Discord chat bot that uses OpenAI's GPT-3.5-turbo model to generate responses to user messages. The bot is triggered when a message starts with the "!" character and responds with a message generated by the OpenAI API.
-
Clone the repository to your local machine.
git clone https://github.com/githmin/gpt-3.5-discord-chat-bot.git
-
Install the required dependencies by running the following command
npm install
-
Create a
.env
file in the root of the project and set the following environment variablesDiscord_Token=<YOUR_DISCORD_TOKEN>
OpenAI_API=<YOUR_OPENAI_API_KEY>
Note: Replace the placeholders with your actual values.
-
Start the bot by running the following command:
node index.js
The bot uses the following dependencies:
dotenv
- To load environment variables from the.env
file.discord.js
- To interact with the Discord API.openai
- To access the OpenAI GPT-3.5-turbo model API.
The bot listens to messages in a specific Discord channel identified by Channel_ID
environment variable. It generates a response to any message that starts with the "!" character. The bot generates the response using the OpenAI GPT-3.5-turbo model and sends it as a reply to the user who sent the message. The bot has access to last 20 messages to build a context.
ChatGPT and Discord.JS
#Made with 🤍 by Githmin Jayawardhana