Unity is an AI Discord bot that chats, remembers, and generates images and code. It uses the Pollinations.ai API, switches models, and saves conversations.
- Remembers chats and channel notes
- Auto-generates images
- Formats code
- Switches AI models per user
- Logs activity
- Python 3.8–3.11
- Discord Bot Token
- Pollinations.ai API Token (for backend access)
- Internet
discord.py
≥ 2.0.0aiohttp
aiofiles
python-dotenv
- Download the files and put them in one folder.
- Get a Discord Bot Token:
- Go to https://discord.com/developers/applications
- Click New Application (top right)
- Enter a name (e.g.,
UnityBot
), click Create - Click Bot in left menu
- Click Add Bot (under Bot section)
- Click Reset Token (under Token), confirm, copy token
- Either set a system environment variable
DISCORD_TOKEN=your_token_here
or create a.env
file with the same line
- Get a Pollinations.ai API Token:
- Go to https://auth.pollinations.ai/
- Sign in (first login auto-assigns Seed tier)
- Click [Re]Generate Token
- Copy the token (e.g.,
DFH4rdfH4hdfDFk
) - Either set a system environment variable
POLLINATIONS_TOKEN=your_token_here
or add it to the.env
file - Warning: Never share the token publicly or commit it to Git
- Install dependencies:
- Open terminal/command prompt in folder
- Run:
pip install -U pip
(updates pip if needed) - Run:
pip install -r requirements.txt
- Run the bot:
- Double-click
RUN_BOT.bat
(Windows) or runpython bot.py
- Double-click
- On Linux run
./setup.sh
(creates a virtual environment and installs dependencies) - On Windows run
setup.bat
- To install a Linux system service run
./install.sh
(service runs as the invoking user)
The setup scripts install a prebuilt Python 3.8+ if missing and create a local virtual environment for dependencies, preventing system-wide package changes.
- On Linux run
./update.sh
- On Windows run
update.bat
- The bot also checks GitHub every 15 minutes and updates automatically
!unityhelp
– Show commands/models!setmodel
– Pick AI model (DM)!savememory <text>
– Save channel note!wipe
– Clear chat history
Examples:
- "Write a Python function"
- "Generate an image of a forest"
- "Remember I like tea" (then
!savememory
)
- Memory: Last 20 messages/user/model, 5 channel notes, saved in
chat_data.json
- Images: Detects "image"/"draw", uses Pollinations.ai
- Models: User-picked, defaults to
unity
- Text: <2000 chars = message, 2000–4096 chars = embed, >4096 chars =
.txt
file
bot.py
– Main botapi_client.py
– API callsmessage_handler.py
– Message handlingmemory_manager.py
– Memorycommands.py
– Commandsconfig.py
– Settings (loads tokens from environment variables or.env
)data_manager.py
– Data saverequirements.txt
– Dependencies.env
– Optional file for tokens (keep secret)system_instructions.txt
– AI rulesRUN_BOT.bat
– Start scriptlogs/
–application.log
,chat_data.json
- Won’t start? Check tokens in environment variables or
.env
, Python version, reinstall dependencies - No DMs? Enable "Allow DMs from server members" in Discord
- Slow? Check
logs/application.log
, restart - No images/text? Verify tokens in
.env
, use "generate an image of..."
- Edit
config.py
:max_history
(20),max_memories
(5), add code/image keywords - Edit
system_instructions.txt
for AI style
- Don’t share tokens or
.env
- Chats saved in
chat_data.json
- Only Pollinations.ai gets requests
- Remembers your style
- Saves channel vibes
- Adds images/code
- Adapts to users
- Fits any server
Check logs or restart if stuck. More chats = better Unity!