https://github.com/hmes98318/chatgpt-discord-bot
Discord ChatGPT and Image Generator Bot
https://github.com/hmes98318/chatgpt-discord-bot
chatgpt chatgpt-bot chatgpt-discord discord-bot discord-js
Last synced: 13 days ago
JSON representation
Discord ChatGPT and Image Generator Bot
- Host: GitHub
- URL: https://github.com/hmes98318/chatgpt-discord-bot
- Owner: hmes98318
- License: gpl-3.0
- Created: 2022-12-11T15:29:33.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-16T14:46:29.000Z (almost 2 years ago)
- Last Synced: 2025-03-24T04:11:13.312Z (29 days ago)
- Topics: chatgpt, chatgpt-bot, chatgpt-discord, discord-bot, discord-js
- Language: TypeScript
- Homepage:
- Size: 1.73 MB
- Stars: 16
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
A Discord chatbot powered by OpenAI's [**GPT3.5**](https://platform.openai.com/docs/models/gpt-3-5) model and [**DALL·E**](https://platform.openai.com/docs/models/dall-e) image generation model.
## Installation
### Precondition
* TypeScript `4.9`
* Node.js `v18`### Clone the repository
```
git clone https://github.com/hmes98318/ChatGPT-Discord-Bot.git
```
or [**click here**](https://github.com/hmes98318/ChatGPT-Discord-Bot/releases) to download### Install the dependencies
install all the dependencies from [`package.json`](./package.json)
```
npm install
```## Configure environment
[`.env`](./.env)
```env
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.
#### Get the OpenAI api key :
* 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`.## Running the script
Production
```
npm run start
```
Development
```
npm run dev
```## Usage
Text Commands:
* `?chat ` : chat with the ChatAI Bot
* `?img ` : Generate AI images
* `?help` : get command helpSlash 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.## Example
#### Text chat![]()
#### Image generation
#### Remember previous few one message example