A Discord chatbot powered by OpenAI's GPT3.5 model and DALL·E image generation model.
- TypeScript
4.9
- Node.js
v18
git clone https://github.com/hmes98318/ChatGPT-Discord-Bot.git
or click here to download
install all the dependencies from package.json
npm install
PREFIX = "?"
PLAYING = "?help"
TOKEN = "discord_bot_token"
OPENAI_API_TOKEN = "openai_api_token"
# Text chat
OPENAI_API_MODEL = "gpt-3.5-turbo"
BOT_MAX_REPLY_COUNT = 5
BOT_MAX_TEXT_LENGTH = 1000
# Image generation
OPENAI_API_IMAGE_SIZE = "512x512"
OPENAI_API_IMAGE_COUNT = 1
OPENAI_API_IMAGE_RESPONSE_FORMAT = "url"
# API setup
OPENAI_API_USER = "user"
OPENAI_API_MAX_TOKEN = 1000
OPENAI_API_TIMEOUT = 30
Detailed description
OPENAI_API_MODEL
: GPT models list https://beta.openai.com/docs/models.
MAX_REPLY_COUNT
: Number of previous messages the bot remembers.
MAX_TEXT_LENGTH
: Maximum send message length.
OPENAI_API_IMAGE_SIZE
: Generate image size. [ 1024x1024
| 256x256
| 512x512
]
OPENAI_API_IMAGE_COUNT
: Number of generated images.
OPENAI_API_IMAGE_RESPONSE_FORMAT
: The format in which the generated images are returned.
OPENAI_API_USER
: Chat Completion Request Message Role Enum. [ user
| system
| assistant
]
OPENAI_API_MAX_TOKEN
: Bot maximum reply message length.
OPENAI_TIMEOUT
: Reply message maximum waiting timeout.
- Go to https://beta.openai.com/account/api-keys and log in or sign up.
- Create new secret key.
- Copy the secret key to
OPENAI_API_TOKEN
.
Production
npm run start
Development
npm run dev
Text Commands:
?chat <message>
: chat with the ChatAI Bot?img <prompt>
: Generate AI images?help
: get command help
Slash Commands:
/chat
/image
/help
NOTE: The remember effect is only useful when using Text Commands Reply.
You have to reply to the previous message to trigger but it will increase the consumption of tokens.