This is a bot for Discord that uses OpenAI's Chat Completion API (a.k.a. ChatGPT) to have conversations with members in a server.
Model support currently includes GPT-3.5 (gpt-3.5-turbo
) and GPT-4 (gpt-4
).
I simply made this because it seems like every other developer is experimenting with AI right now, and since OpenAI recently announced their chat completion API, I thought now is probably a better time than never. There's no other motiviation behind this than just wanting an excuse to play around with ChatGPT from a development view.
NOTE: OpenAI's Chat Completion API is not free, though still quite cheap, and thus requires setting up a recurring billing account.
NOTE: The GPT-4 model is currently in a limited beta, if you have not been granted access then your Discord server members will only be able to use the GPT-3.5 model.
- Download & extract the latest stable release.
- Open a terminal in the newly created directory.
- Install production dependencies via
npm install --omit=dev
. - Create an environment variables file (
.env
) and add the required properties. - Launch via
node .
. - Use the
/conversation
slash command in your Discord server.
- Download the latest stable Docker image for your platform.
- Create a container via
docker container create --name discord-conversation-bot --interactive --tty --restart on-failure ghcr.io/discord-conversation-bot
.- Ensure to add
--env
flags for each of the required properties, or create an environment file and use the--env-file
flag. - Ensure to append the appropriate tag for your platform to the image name (e.g.,
:latest-ubuntu-amd64
,:latest-windows-amd64
, etc.)
- Ensure to add
- Start the container via
docker container start discord-conversation-bot
. - Use the
/conversation
slash command in your Discord server.
Environment variables are used to configure functionality. The following are required:
DISCORD_BOT_TOKEN
should be set to the bot token of your Discord application.Removed in version 1.1.0.DISCORD_GUILD_ID
should be set to the ID of your server.OPENAI_API_KEY
should be set to your OpenAI account API key.
- Clone this repository via
git clone https://github.com/viral32111/discord-conversation-bot
. - Open a terminal in the repository's directory.
- Install production & development dependencies via
npm install
. - Create an environment variables file (
.env
) and add the required properties. - Launch via
npm start
. - Use the
/conversation
slash command in your Discord server.
- Discord.js Documentation
- Discord.js Guide
- OpenAI Chat Completion Guide
- OpenAI Chat API Reference
- NPM log4js package
- NPM dotenv package
- NPM openai package
Copyright (C) 2023 viral32111.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses.