A feature-rich Discord bot built with Python and discord.py, optimized for 24/7 operation on Termux.
- 🍖 Virtual Pet System: The bot has a life of its own! It gets hungry over time and loses health if not fed.
- 📊 Persistent Stats: Uses aiosqlite to save health and hunger data, so stats aren't lost when the bot restarts.
- 🔄 Auto-Restart Engine: Includes a shell script that automatically revives the bot if it crashes or is told to !restart.
- 💬 Enhanced Social Logic: Prevents "Hi" and "Bye" spam by detecting duplicates and managing permissions.
- 🛠️ Admin Suite: Advanced !purge, !restart, and !stop commands for trusted users.
1. Prerequisites (Termux) Install the necessary packages on your Android device:
pkg update && pkg upgrade
pkg install python
pip install discord.py python-dotenv aiosqlite2. Configuration (.env) Create a .env file to store your secrets securely:
nano .envPaste the following and replace with your actual data:
DISCORD_TOKEN=YOUR_BOT_TOKEN_HERE
TRUSTED_USERS=YOUR_USER_ID, ANOTHER_USER_IDto save any files created by nano, press ctrl+x, press Y, press enter
3. Creating the Auto-Restart Script (start.sh) This script acts as a "bodyguard" to keep your bot running.
- Create the file:
nano start.sh- Paste this logic:
#!/bin/bash
while true
do
echo "Starting Bot..."
python bot1.py
status=$?
if [ $status -eq 0 ]; then
echo "✅ Bot stopped manually. Goodbye!"
break
else
echo "🔄 Restarting in 3 seconds..."
sleep 3
fi
doneto save any files created by nano, press ctrl+x, press Y, press enter
- Crucial step: Give Termux permission to run this script:
chmod +x start.shInstead of running the python file directly, use the starter script:
./start.sh!battery - Shows the battery status using termux-battery-status command (termux-api) • this command only works when this bot is run by termux app on Android
- Add ghost of bot when it reaches 0 health
- Make logic for ghost of bot so it would not respond to any commands even if it's online (except revive command)
- Add revive command
- Add battery command
- Add XP system
- Remove bot to bot Hi and Bye logic (due to prevent unsatisfaction)