This is an example Discord Chat Bot based on Open Ai and Discord.js Library. This code is capable of remembering the previous conversations and can reply accordingly.
- A Discord Bot with its Token.
- Open Ai API Key Get Key from here
- Create a file named
.env
. - Enter the following details to it:
token="YOUR TOKEN"
OPENAI_API_KEY="API KEY"
- In config.json, enter the channel-id's in which you want to enable the bot.
- Save the file. Open Terminal in the Project Directory.
- Run:
npm i
node index.js
- You are done.
To get Custom Response, just head to prompt
variable, and change things accordingly. Do not add so many information, otherwise you will exhaust your free credits quickly.
- Error: Status Code 500 : This means there is an server error from OpenAi
- Error: Status Code 429 : You have been rate-limited from OpenAi
Join our Discord Servers, to get support: