A comprehensive Discord bot for automating FiveM server management, updates, and backups with support for both TCAdmin and Windows Service integration.
- π Automated FiveM Updates: Download and install server artifacts from FiveM Repository
- πΎ Smart Caching: Reuse downloaded files for faster operations
- β‘ Pre-Download: Download artifacts without updating servers
- π§Ή Automatic Cleanup: Configurable cleanup of old downloaded files
- π₯οΈ TCAdmin Integration: Command-line based server control (reliable, no web auth issues)
- βοΈ Windows Service Support: Direct Windows service management
- π Mixed Environments: Different management methods per server (dev/live)
βΆοΈ Independent Control: Start/stop servers without updating- π Status Monitoring: Real-time server status checking
- π‘οΈ Automatic Backups: Server files backed up before every update
- π Version Tracking: Smart backup naming based on current server version
- π ServerData Protection: Separate backup/restore of server configurations and data
- π Complete Rollback: Restore servers to any previous backup
- ποΈ Backup Management: List, delete, and organize server backups
- π Role-Based Access: Discord role restrictions
- π€ Individual Permissions: Granular user-specific access control
- π’ Channel Restrictions: Limit bot responses to designated channels
- π Per-Server Security: Different access levels for different servers
- π― Per-Server Settings: Independent configuration for each server type
- π Customizable Commands: Configure all command names and prefixes
- π§ Multiple Management Types: TCAdmin, Windows Service, or File-only per server
- π Custom Paths: Configurable file locations and ServerData paths
All commands respect your configured prefix (default !) and can be customized.
!download <artifact_number> [force]
Download artifact without updating server
!download 17346- Download artifact 17346!download 17346 force- Re-download even if cached
!update <artifact_number> <server_type>
Update server with new artifact (includes automatic backup)
!update 17346 dev- Update dev server!update 17346 live- Update live server
!start <server_type>
Start server (TCAdmin or Windows Service)
!start dev- Start development server!start live- Start live server
!stop <server_type>
Stop server (TCAdmin or Windows Service)
!stop dev- Stop development server!stop live- Stop live server
!status [server_type]
Check server status and version
!status- Check all servers!status dev- Check specific server
!backups <action> <server_type> [backup_name]
Manage server backups
!backups list dev- List all dev server backups!backups delete dev server_backup_17346- Delete specific backup!backups delete dev all- Delete all dev backups
!rollback <server_type> <backup_name>
Restore server from backup
!rollback dev server_backup_17346- Restore dev server from backup
!version [server_type]
Check current server versions
!version- Check all server versions!version live- Check specific server version
!config
Display current bot configuration
!help
Show all available commands with examples
!cleanup [days]
Clean up old downloaded files
!cleanup- Use default cleanup period!cleanup 7- Delete files older than 7 days
The bot uses config.ini for all settings. Copy config.ini.example and customize for your setup.
[discord]
discord_token = your_discord_bot_token_here
command_prefix = !
response_channel = 1234567890123456789 # Optional: restrict to specific channel
allowed_roles = 1234567890123456789 # Optional: comma-separated role IDs
allowed_discord_users = 987654321098765432 # Optional: comma-separated user IDs
# Customize command names (optional)
update_command = update
download_command = download
start_command = start
stop_command = stop
status_command = status
version_command = version
backups_command = backups
rollback_command = rollback
cleanup_command = cleanup
config_command = config
help_command = help[files]
base_directory = ./bot_files/ # Base directory for all bot files
download_directory = downloads # Subdirectory for artifact cache
temp_directory = temp # Subdirectory for temporary files
keep_downloaded_files = true # Keep downloaded artifacts for reuse
auto_cleanup_days = 30 # Auto-delete files older than X days (0 = disabled)Configure each server type independently with different management methods:
[dev]
ServerFiles = "G:/GTAV/dev/server"
ServerData = "G:/GTAV/dev/server-data" # Optional: separate server data location
TCADMIN_Enabled = True
Service_Enabled = False
tcadmin_executable = C:\TCAdmin2\Monitor\TCAdminServiceBrowser.exe
tcadmin_service_id = 23[live]
ServerFiles = "G:/GTAV/live/server"
TCADMIN_Enabled = False
Service_Enabled = True
Service_Name = "FXServer"[staging]
ServerFiles = "G:/GTAV/staging/server"
TCADMIN_Enabled = False
Service_Enabled = False
# No server management - file updates only[dev]
# Development uses TCAdmin
ServerFiles = "G:/GTAV/dev/server"
TCADMIN_Enabled = True
Service_Enabled = False
tcadmin_executable = C:\TCAdmin2\Monitor\TCAdminServiceBrowser.exe
tcadmin_service_id = 23
[live]
# Production uses Windows Service
ServerFiles = "G:/GTAV/live/server"
ServerData = "G:/GTAV/live/server-data"
TCADMIN_Enabled = False
Service_Enabled = True
Service_Name = "FXServer"- Python 3.8+
- Discord Bot Token (Create one here)
- FiveM Server (Windows)
- TCAdmin (optional) or Windows Service setup
- Create Discord Application: Go to Discord Developer Portal and create new application
- Create Bot: In your application, go to "Bot" section and create a bot
- Copy Token: Save your bot token for the configuration file
- Invite Bot: Use this URL template to invite your bot (replace
YOUR_APPLICATION_IDwith your actual application ID):
https://discord.com/api/oauth2/authorize?client_id=YOUR_APPLICATION_ID&permissions=379904&scope=bot
Required Permissions (included in the URL above):
- β Send Messages
- β Read Messages
- β Read Message History
- β Use External Emojis
- β Embed Links
- β Attach Files
Finding Your Application ID:
- Go to your Discord Developer Portal
- Select your application
- Copy the "Application ID" from the General Information page
Example Invite URL:
https://discord.com/api/oauth2/authorize?client_id=123456789012345678&permissions=379904&scope=bot
# Clone or download the repository
git clone https://github.com/DrunkMunki/FiveMUpdateBot.git
cd FiveMUpdateBot
# Install Python dependencies
pip install -r requirements.txt
# Copy example configuration
copy config.ini.example config.iniEdit config.ini with your settings:
- Discord Token: Add your bot token from Discord Developer Portal
- Server Paths: Set your FiveM server file locations
- Management Method: Choose TCAdmin, Windows Service, or File-only for each server
- Permissions: Configure Discord roles/users who can use the bot
- Find TCAdminServiceBrowser.exe: Usually in
C:\TCAdmin2\Monitor\ - Get Service IDs: Check TCAdmin panel URLs (
/Service/Details/12345β ID is12345) - Test Command: Run
C:\TCAdmin2\Monitor\TCAdminServiceBrowser.exe -service=YOUR_ID -command=stop
# Start the bot
python main.py
# Or use the batch file (Windows)
start_bot.bat- π Artifact Lookup: Bot checks FiveM repository for requested artifact
- πΎ Cache Check: Uses cached file if available (unless
forcespecified) - π₯ Download: Downloads artifact if not cached
- πΎ Backup Creation: Creates version-aware backup of current server files
- π ServerData Backup: Backs up server data separately (if configured)
- βΉοΈ Server Stop: Stops server using configured method (TCAdmin/Service)
- π File Lock Check: Ensures no processes are locking server files
- π¦ Extraction: Extracts new artifact to temporary location
- π File Copy: Updates server files with new content
- π ServerData Restore: Restores server data from backup
- π Version Tracking: Creates
version.txtwith current artifact number βΆοΈ Server Start: Starts server using configured method- π§Ή Cleanup: Removes temporary files (keeps cache if configured)
- Version-aware:
server_backup_17346(uses current version fromversion.txt) - Incremental:
server_bak1,server_bak2(if no version info) - Collision avoidance: Automatically adds numbers to prevent overwrites
- π₯οΈ Server Files: Complete server directory backup
- π ServerData: Separate backup of configurations, databases, resources
- π₯οΈπΎ Combined: Server backups that include ServerData inside
Backups are created in the parent directory of your server files:
G:/GTAV/
βββ dev/
β βββ server/ # Current server files
β βββ server_backup_17346/ # Previous version backup
β βββ server_backup_17200/ # Older version backup
βββ live/
βββ server/ # Current server files
βββ server_backup_17400/ # Previous version backup
- Role-based: Restrict commands to specific Discord roles
- User-specific: Grant access to individual users regardless of roles
- Channel restriction: Limit bot responses to designated channels
- Per-command control: Same security applies to all commands
[discord]
# Allow these roles to use the bot
allowed_roles = 123456789,987654321
# Also allow these specific users (even if they don't have the role)
allowed_discord_users = 111222333444555666,777888999000111222
# Optional: Only respond in this channel
response_channel = 555666777888999000!status
Dev: β
Running - Version: 17346 (TCAdmin)
Live: β
Running - Version: 17400 (Service (FXServer))
!status dev
β
Dev Server: Running (Version: 17346)
π§ Management: TCAdmin
Each server maintains a version.txt file with the current artifact version:
G:/GTAV/dev/server/version.txt β Contains: 17346
G:/GTAV/live/server/version.txt β Contains: 17400
{base_directory}/ # Configured base directory
βββ downloads/ # Artifact cache
β βββ 17346.7z # Cached artifacts
β βββ 17400.7z
βββ temp/ # Temporary extraction
βββ extract_17346_*/ # Temporary folders (auto-deleted)
- Automatic: Delete files older than configured days
- Manual: Use
!cleanupcommand - Startup: Clean old files when bot starts
- Disable: Set
auto_cleanup_days = 0to disable
Run different servers with different management methods:
- Dev Server: TCAdmin for full control panel integration
- Live Server: Windows Service for simple, reliable operation
- Test Server: File-only for development environments
- Automatic Detection: Finds ServerData in existing server backups
- Flexible Paths: Configure separate ServerData locations
- Preservation: ServerData is backed up and restored during updates
- Fallback Handling: Copies ServerData from artifacts for initial setup
- Automatic Restart: Tries to restart servers if update fails
- Backup Restoration: Easy rollback if updates cause issues
- File Lock Detection: Identifies and waits for locked files
- Detailed Logging: Comprehensive error information
- Add
tcadmin_executable = C:\TCAdmin2\Monitor\TCAdminServiceBrowser.exe - Verify the path exists and is accessible
- Check Windows Service name is correct
- Use
services.mscto verify service exists - Ensure bot has permission to control services
- Verify artifact number exists on FiveM repository
- Check internet connection
- Try a different artifact number
- Set either
TCADMIN_Enabled = TrueorService_Enabled = True - Configure the required fields for your chosen method
# Test TCAdmin command (replace with your service ID)
C:\TCAdmin2\Monitor\TCAdminServiceBrowser.exe -service=23 -command=stop
# Test Windows Service
sc query "FXServer"
sc stop "FXServer"
sc start "FXServer"FiveMUpdateBot/
βββ main.py # Main bot application
βββ config.ini # Your configuration (create from example)
βββ config.ini.example # Example configuration with comments
βββ requirements.txt # Python dependencies
βββ README.md # This documentation
βββ artifacts.txt # Artifact URL cache (auto-generated)
βββ setup_environment.py # Interactive setup script (optional)
This bot has been extensively enhanced with enterprise-level features:
- β Per-server configuration - Mixed TCAdmin/Service environments
- β Command-line TCAdmin - Reliable, no web authentication issues
- β Windows Service integration - Direct service control
- β Intelligent backup system - Version-aware naming and management
- β ServerData protection - Separate backup/restore of server configurations
- β Independent server control - Start/stop without updating
- β Rollback functionality - Restore from any backup
- β Enhanced permissions - Individual user access control
- β Version tracking - Automatic version.txt management
- β Mixed management types - Different methods per server
This project is provided as-is for educational and personal use. Please ensure compliance with:
- FiveM's Terms of Service
- Discord's Developer Terms of Service
- Your server hosting provider's policies
For issues and questions:
- Check this README - Most common issues are covered
- Review your configuration - Use
!configcommand to verify settings - Test components individually - Try TCAdmin/Service commands manually
- Check file permissions - Ensure bot can read/write to configured paths
- Verify Discord permissions - Ensure bot has necessary Discord permissions