I wanted to see if there was a simple way of integrating OpenAI's language model GPT3 as a bot in discord. I learnt that implementing API can be both simple and fun.
Prerequesits are: You need to setup a Discord bot and invite the bot to your server. You need Both a Discord and OpenAI api key.
- Clone the repository
- Make sure you have node.js installed on your computer.
- Crate a file named .env in the project folder that contains the following two lines (replace the placeholder text with your key):
DISCORD_TOKEN="YOUR DISCORD API KEY HERE"
OPENAI_API_KEY="YOUR OPENAI API KEY HERE"
- Write
npm install
in terminal. - Run the bot by typing into the terminal in the folder of the project
node index.js
After you have added the bot to your Discord server and followed the instructions above do one of the following:
In any chat on the server where the bot has access type: AI:
followed by whatever you want to ask the OpenAI GPT3 model.
In any chat on the server where the bot has access type: AIPICTURE:
followed by the what type of picture you want the AI to generate.