Discord-Raid-bot/README.md

311 lines
7.9 KiB
Markdown
Raw Normal View History

2025-08-13 12:07:16 +00:00
# RTF Discord Bot - Personal Best Tracker
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
A Discord Bot to track Personal Best (PB) for each clan boss
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
## 🎮 Features
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
- **Multi-Boss Support** : Hydra (4 difficulties), Chimera (6 difficulties), Clan vs Clan
- **Cluster support** : RTF, RTFC, RTFR with split leaderboards
- **Saves Screenshots** : Storage and display of proof
- **SQLite Databse** : Persistent and efficient storage
- **Automatic Cleanupe** : Old screenshots deleted when new records are set
- **User-Friendly Interface** : Simple commands and Discord embeds
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
## 📋 Requirements
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
### Softwares required
2025-08-13 12:07:16 +00:00
- **Python 3.9+**
2025-08-13 13:13:06 +00:00
- **Container Station** (QNAP) or **Docker**
2025-08-13 12:07:16 +00:00
- **Discord Bot Token** ([Discord Developer Portal](https://discord.com/developers/applications))
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
### Python dependencies
2025-08-13 12:07:16 +00:00
```
discord.py>=2.3.0
aiohttp>=3.8.0
```
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
## 🏗Nas Folder Structure
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
Create the following structure on your QNAP:
2025-08-13 12:07:16 +00:00
```
/share/Container/discord-bot/
2025-08-22 13:25:34 +00:00
├── bot.py # Script principal minimal
├── config.py # Variables centrales (token, channel ID)
├── requirements.txt # Dépendances Python
├── .env # Tokens, IDs de channel
├── docker-compose.yml
├── bot_data.db # SQLite DB
├── cogs/ # Toutes les commandes du bot
│ ├── guide.py # Commande !guide
│ ├── pbhydra.py # Commandes PB Hydra
│ ├── pbchimera.py # Commandes PB Chimera
│ ├── pbcvc.py # Commandes PB CvC
│ ├── top10.py # Classements globaux
│ └── mystats.py # Commande !mystats
├── utils/ # Fonctions utilitaires partagées
│ ├── DatabaseManager_class.py # Gestion DB SQLite
│ ├── ScreenshotManager_class.py # Gestion des screenshots
│ ├── leaderboard_handler.py # Gestion tableau de score
│ ├── pbhandler.py # Gestion des pbs
│ └── helpers.py # Fonctions génériques (ex: channel autorisé)
├── logs/ # Logs du bot (optionnel)
└── screenshots/ # Screenshots organisés par boss/difficulté
2025-08-13 12:07:16 +00:00
├── hydra/
├── chimera/
└── cvc/
```
2025-08-13 13:13:06 +00:00
## 🐳 Docker Installation (Recommended)
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
### 1. Create `requirements.txt`
2025-08-13 12:07:16 +00:00
```txt
discord.py>=2.3.0
aiohttp>=3.8.0
python-dotenv>=1.0.0
```
2025-08-13 13:13:06 +00:00
### 2. Create `.env`
2025-08-13 12:07:16 +00:00
```env
DISCORD_TOKEN=your_bot_token_here
AUTHORIZED_CHANNEL_ID=your_channel_id_here
```
2025-08-13 13:13:06 +00:00
### 3. Create `Dockerfile`
2025-08-13 12:07:16 +00:00
```dockerfile
FROM python:3.9-slim
WORKDIR /app
2025-08-13 13:13:06 +00:00
# Install system dependencies
2025-08-13 12:07:16 +00:00
RUN apt-get update && apt-get install -y \
sqlite3 \
&& rm -rf /var/lib/apt/lists/*
2025-08-13 13:13:06 +00:00
# Copy dependency file
2025-08-13 12:07:16 +00:00
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
# Copy source code
2025-08-13 12:07:16 +00:00
COPY bot.py .
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
# Create required folders
2025-08-13 12:07:16 +00:00
RUN mkdir -p screenshots/hydra/normal screenshots/hydra/hard screenshots/hydra/brutal screenshots/hydra/nightmare \
screenshots/chimera/easy screenshots/chimera/normal screenshots/chimera/hard screenshots/chimera/brutal screenshots/chimera/nightmare screenshots/chimera/ultra \
screenshots/cvc
2025-08-13 13:13:06 +00:00
# Environment variables
2025-08-13 12:07:16 +00:00
ENV PYTHONUNBUFFERED=1
CMD ["python", "bot.py"]
```
2025-08-13 13:13:06 +00:00
### 4. Create `docker-compose.yml`
2025-08-13 12:07:16 +00:00
```yaml
version: '3.8'
services:
discord-bot:
build: .
restart: unless-stopped
env_file:
- .env
volumes:
- ./screenshots:/app/screenshots
- ./bot_data.db:/app/bot_data.db
- ./logs:/app/logs
environment:
- TZ=Europe/Paris
container_name: rtf-discord-bot
2025-08-13 13:13:06 +00:00
# Optional: Resource limits
2025-08-13 12:07:16 +00:00
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 128M
```
## ⚙️ Configuration
2025-08-13 13:13:06 +00:00
1. Get Discord Token
Go to Discord Developer Portal (https://discord.com/developers/applications)
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
Create a new Application
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
In "Bot" → "Token" → Copy token
In "Bot" → "Privileged Gateway Intents" → Enable "Message Content Intent"
2. Get Channel ID
Enable Developer Mode in Discord (Settings → Advanced)
Right-click your channel → "Copy ID"
3. Invite the Bot to Your Server
Generate an invitation URL with these permissions:
Send Messages
Read Message History
Attach Files
Use External Emojis
Add Reactions
2025-08-13 12:07:16 +00:00
URL : `https://discord.com/api/oauth2/authorize?client_id=YOUR_BOT_ID&permissions=378944&scope=bot`
## 🚀 Déploiement sur QNAP
### Via Container Station (Recommandé)
2025-08-13 13:13:06 +00:00
1. Install Container Station via App Center
2. Create /share/Container/discord-bot/
3. Copy all files into this folder
4. Edit .env with your tokens
5. Container Station → "Create" → "Create Application via docker-compose"
6. Select your docker-compose.yml
7. Start the container
2025-08-13 12:07:16 +00:00
### Via SSH (Alternative)
2025-04-29 07:28:29 +00:00
```bash
2025-08-13 13:13:06 +00:00
# Connect to QNAP
ssh admin@YOUR_QNAP_IP
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
# Navigate to folder
2025-08-13 12:07:16 +00:00
cd /share/Container/discord-bot/
2025-08-13 13:13:06 +00:00
# Install dependencies (if Python is installed)
2025-08-13 12:07:16 +00:00
pip3 install -r requirements.txt
2025-08-13 13:13:06 +00:00
# Test run
2025-08-13 12:07:16 +00:00
python3 bot.py
2025-08-13 13:13:06 +00:00
# Create auto-start service via QNAP interface
# Control Panel → Applications → Autorun
# Add: cd /share/Container/discord-bot && python3 bot.py &
2025-04-29 07:28:29 +00:00
```
2025-08-13 13:13:06 +00:00
## 📊 SQLite Database
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
**Automatic Structure**
The bot automatically creates the necessary tables:
- Table users: PBs for all bosses and difficulties
- Table pb_history: Complete record history
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
### Main columns
2025-08-13 12:07:16 +00:00
```sql
-- Hydra
pb_hydra_normal, pb_hydra_normal_screenshot, pb_hydra_normal_date
pb_hydra_hard, pb_hydra_hard_screenshot, pb_hydra_hard_date
pb_hydra_brutal, pb_hydra_brutal_screenshot, pb_hydra_brutal_date
pb_hydra_nightmare, pb_hydra_nightmare_screenshot, pb_hydra_nightmare_date
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
-- Chimera (6 similar difficulties)
2025-08-13 12:07:16 +00:00
pb_chimera_easy, pb_chimera_normal, pb_chimera_hard,
pb_chimera_brutal, pb_chimera_nightmare, pb_chimera_ultra
2025-04-29 07:28:29 +00:00
2025-08-13 12:07:16 +00:00
-- CvC
pb_cvc, pb_cvc_screenshot, pb_cvc_date
```
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
## 🎯 Commands Usage
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
### Submit a PB
2025-08-13 12:07:16 +00:00
```
2025-08-13 13:13:06 +00:00
!pbhydra brutal 1500000 (+ attached screenshot)
!pbchimera ultra 2000000 (+ attached screenshot)
!pbcvc 1800000 (+ attached screenshot)
2025-08-13 12:07:16 +00:00
```
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
### View PBs
2025-08-13 12:07:16 +00:00
```
2025-08-13 13:13:06 +00:00
!pbhydra nightmare (your PB)
!pbchimera easy Alice (Alice's PB)
!mystats (all your PBs)
2025-08-13 12:07:16 +00:00
```
2025-08-13 13:13:06 +00:00
### Leaderboards
2025-08-13 12:07:16 +00:00
```
!top10hydra brutal (global)
2025-08-13 13:13:06 +00:00
!rtfhydra nightmare (for RTF)
!rtfcchimera ultra (for RTFC)
2025-08-13 12:07:16 +00:00
```
## 🔧 Maintenance
2025-04-29 07:28:29 +00:00
2025-08-13 12:07:16 +00:00
### Logs
2025-04-29 07:28:29 +00:00
```bash
2025-08-13 12:07:16 +00:00
# Via Docker
docker logs rtf-discord-bot
# Via Container Station
2025-08-13 13:13:06 +00:00
Container Station → Your container → Logs
2025-04-29 07:28:29 +00:00
```
2025-08-13 13:13:06 +00:00
### Backup
2025-08-13 12:07:16 +00:00
```bash
2025-08-13 13:13:06 +00:00
# Backup database
2025-08-13 12:07:16 +00:00
cp bot_data.db bot_data_backup_$(date +%Y%m%d).db
2025-08-13 13:13:06 +00:00
# Backup screenshots
2025-08-13 12:07:16 +00:00
tar -czf screenshots_backup_$(date +%Y%m%d).tar.gz screenshots/
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
```
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
### Cleanup
Old screenshots are automatically deleted when a new PB is set.
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
## 🛠️ Troubleshooting
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
### Bot not responding
- Check AUTHORIZED_CHANNEL_ID
- Check bot permissions
- Consult logs for errors
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
### Screenshots Not Saved
- Check screenshots/ folder permissions
- Ensure image format is supported (PNG, JPG, etc.)
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
### Database errors
- Check write permissions on bot_data.db
- If corrupted: delete the file (it will be recreated)
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
## 📈 Performance
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
### Optimized for 50+ Users
- SQLite: Works well up to 100+ concurrent users
- Screenshots: ~2MB per image, auto cleanup
- RAM: ~128MB normal usage
- CPU: Minimal (Discord events only)
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
## 🔒 Security
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
- Discord token in .env (never in code)
- Bot limited to a single channel
- No SSH or system access from bot
- Screenshots stored locally (full control)
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
## 📝 Important Notes
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
- Clans detected automatically: [RTF] Username or [RTF]Username
- Old screenshots deleted automatically on new PB
- Empty leaderboards show an informative message
- Date format: MM/DD/YYYY at HH:MM AM/PM
- Emojis editable in BOSS_CONFIG and CLAN_CONFIG
2025-04-29 07:28:29 +00:00
2025-08-13 13:13:06 +00:00
## 🚀 Possible Extensions
- Add new bosses
- Advanced statistics (averages, progression)
- Export data to Excel
- Web interface to view stats
- Automatic notifications for new records
2025-04-29 07:28:29 +00:00
---
2025-08-13 12:07:16 +00:00
2025-08-13 13:13:06 +00:00
**Developed for the RTF community By Elewyn** 🎮