https://github.com/electronic-mango/openai-dalle-discord-bot
Discord bot for your DALL·E needs.
https://github.com/electronic-mango/openai-dalle-discord-bot
dall-e dall-e-api dalle dalle-3 discord discord-bot hikari hikari-lightbulb openai openai-api
Last synced: 3 months ago
JSON representation
Discord bot for your DALL·E needs.
- Host: GitHub
- URL: https://github.com/electronic-mango/openai-dalle-discord-bot
- Owner: Electronic-Mango
- License: gpl-3.0
- Created: 2024-04-15T19:02:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-15T13:21:41.000Z (about 1 year ago)
- Last Synced: 2024-06-15T14:37:01.329Z (about 1 year ago)
- Topics: dall-e, dall-e-api, dalle, dalle-3, discord, discord-bot, hikari, hikari-lightbulb, openai, openai-api
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple OpenAI image model Discord bot
A simple and unofficial Discord bot wrapping [OpenAI API](https://openai.com/blog/openai-api/) image models (like [DALL·E](https://openai.com/dall-e-3)), build with [`hikari`](https://github.com/hikari-py/hikari) and [`lightbulb`](https://github.com/tandemdude/hikari-lightbulb)!
Bot works on servers for everyone, it will respond to DMs only for bot owner.
## Requirements
This bot was built with `Python 3.12`, [`hikari`](https://github.com/hikari-py/hikari), [`lightbulb`](https://github.com/tandemdude/hikari-lightbulb) and [`openai-python`](https://github.com/openai/openai-python).
Full list of Python requirements is in the `requirements.txt` file, you can use it to install all of them.## Bot permissions
### Message content
This bot requires **message content privileged gateway intent** to function correctly.
This is required as bot can respond to all messages in a given channel.You can enable this content for the whole bot in [Discord Developer Portal](https://discord.com/developers/applications) and specific bot settings.
Currently, bot won't even start without this privileged intent enabled.
## Configuration
Configuration is done through a `.env` file. You can copy example file `.env.example` as `.env` and fill required parameters.
```commandline
cp .env.example .env
```### Discord bot
### Discord bot
Only required parameter is a bot token
```dotenv
BOT_TOKEN=''
```You can also optionally specify file in which all target channels for `start` command can be stored:
```dotenv
SOURCES_PERSISTENCE_FILE=''
```Bot will store all channel IDs where automatic responding is configured in this file.
After bot is restarted (if the specified file still exists and wasn't modified) it will keep responding in previously configured channels.
### OpenAI API
There are two required parameters - [API key](https://platform.openai.com/account/api-keys) and [used model](https://platform.openai.com/docs/models/dall-e).
```dotenv
OPENAI_TOKEN=''
OPENAI_MODEL='dall-e-3 or dall-e-2'
```Through `.env` you can also configure level of logging of OpenAI API through `OPENAI_LOG` parameter.
You can set it to `debug` or `info`.
```dotenv
OPENAI_LOG='debug or info'
```## Commands
All commands work on servers for everyone and in DMs for bot owner.
* `/start` - start generating images for all messages in current channel
* `/quiet_start` - start generating images for all messages in current channel without notifying other users
* `/stop` - stop generating images automatically
* `/quiet_stop` - stop generating images automatically without notifying other users
* `/generate` - generate image based on given prompt
* `generate` - **message command**, generate image based on selected message## Running the bot
You can run the bot from the source code directly, or in a Docker container.
### From source code
1. Create a Discord bot
2. Create [OpenAI API key](https://platform.openai.com/account/api-keys)
3. Install all packages from `requirements.txt`
4. Fill `.env` file
5. Run `main.py` file with Python### Docker
1. Create a Discord bot
2. Create [OpenAI API key](https://platform.openai.com/account/api-keys)
3. Fill `.env` file
4. Run `docker compose up -d --build` in terminalNote that `.env` file is used only for loading environment variables into Docker container through compose.
The file itself isn't added to the container.When using Docker the bot will automatically store channel IDs for purposes of `start` command in `persistence` file located in project root.
## Disclaimer
This bot is in no way affiliated, associated, authorized, endorsed by, or in any way officially connected with OpenAI.
This is an independent and unofficial project.
Use at your own risk.