This is a simple Discord bot I built with discord.py. It tracks user interactions and I've set it up to deploy automatically to my VPS.
I am actively developing this bot and adding more features regularly.
You can invite the bot to your server using this link: Invite Bot
Note: The bot is currently deployed on a VPS for showcase purposes. I cannot guarantee 100% uptime.
To maintain stability, I use a two-bot system:
- Production Bot: Connected to my
mainbranch. It runs on my Hetzner VPS and uses my production API token. - Testing Bot: I use this for local development and testing new features. It uses a separate API token so I don't interfere with the live bot.
-
Clone the repository:
git clone <your-repo-url> cd DiscordBot
-
Set up a virtual environment:
python -m venv venv source venv/bin/activate pip install -r requirements.txt -
Configure Environment Variables: Create a
.envfile in the root directory:DISCORD_API_TOKEN=your_testing_bot_token_here
-
Run the bot:
python bot.py
I've implemented a fully automated CI/CD pipeline using GitHub Actions.
Whenever I push to the main branch, my deployment workflow (.github/workflows/deploy.yml) is triggered:
- It connects to my Hetzner VPS via SSH.
- It executes
deploy.sh, which:- Pulls my latest code from the
mainbranch. - Updates dependencies in the virtual environment.
- Restarts my
discordbotservice viasystemctl.
- Pulls my latest code from the
I use the following GitHub Secrets for my deployment workflow:
VPS_HOST: My VPS IP address or hostname.VPS_USERNAME: My SSH username for deployment.VPS_SSH_KEY: My private SSH key for authentication.