This is a Node.js application that creates a chat bot for Discord using Discord.js and OpenAI API. The bot can respond to messages in a specific channel and can also execute custom commands.
dotenv- loads environment variables from a .env filediscord.js- provides a powerful interface for interacting with the Discord APIopenai- provides an API for accessing OpenAI's powerful AI modelschalk- provides terminal stylingora- provides loading spinnersfs- provides file system accesspath- provides path manipulation utilities
Before running the application, you will need to create a .env file and add your Discord bot token and OpenAI API key.
BOT_TOKEN=<your Discord bot token>
OPENAI_API_KEY=<your OpenAI API key>
To install the necessary packages, run the following command:
npm install dotenv discord.js openai chalk ora fs path
To start the bot, run the following command:
node index.js