Small Node.js Typescript Discord bot using the OpenAI API to answer questions.
Started developing this project to learn more about the OpenAI API and how to use it and to try integrating ai in Discord. Discord then released their own ai bot, so I decided to stop developing this project. It's still interesting to see how to use the OpenAI API and how to integrate it in a Discord bot.
- Node.js (v14 or higher)
- npm (v6 or higher)
- Git
- Discord Account
- OpenAI Account
- Create a new application on the Discord Developer Portal
- Create a bot for your application
- Copy the bot token and save it for later
- Invite the bot to your server and give him following permissions
- Send Messages
- Manage Messages
- Read Message History
- Add Reactions
- Create a new API key on the OpenAI Developer Portal
- Copy the API key and save it for later
- Clone the repository
- Install dependencies with
npm install - Create a
.envfile in the root directory with the tokens inside:
DISCORD_TOKEN=<your discord bot token>
OPENAI_API_KEY=<your openai api key>
- Run
npm run buildto build the project - Run
npm run startto start the bot
Open the Discord server you invited the bot to and use one of the commands below.
/ai - Ask the ai a single question
This project is licensed under the MIT License - see the LICENSE file for details.