A simple and unofficial Discord bot wrapping OpenAI API image models (like DALL·E), build with hikari
and lightbulb
!
Bot works on servers for everyone, it will respond to DMs only for bot owner.
This bot was built with Python 3.12
, hikari
, lightbulb
and openai-python
.
Full list of Python requirements is in the requirements.txt
file, you can use it to install all of them.
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 and specific bot settings.
Currently, bot won't even start without this privileged intent enabled.
Configuration is done through a .env
file. You can copy example file .env.example
as .env
and fill required parameters.
cp .env.example .env
Only required parameter is a bot token
BOT_TOKEN='<your secret bot token>'
You can also optionally specify file in which all target channels for start
command can be stored:
SOURCES_PERSISTENCE_FILE='<path to basic 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.
There are two required parameters - API key and used model.
OPENAI_TOKEN='<your secret API key>'
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
.
OPENAI_LOG='debug or info'
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 promptgenerate
- message command, generate image based on selected message
You can run the bot from the source code directly, or in a Docker container.
- Create a Discord bot
- Create OpenAI API key
- Install all packages from
requirements.txt
- Fill
.env
file - Run
main.py
file with Python
- Create a Discord bot
- Create OpenAI API key
- Fill
.env
file - Run
docker compose up -d --build
in terminal
Note 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.
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.