Spy Bot - Monitoring bot for Discord
π€ Spy Bot
A Discord bot for monitoring presence, status, and voice channels with beautiful notifications and detailed statistics for each user!
π Languages
- πΊπΈ English
- π§π· PortuguΓͺs
β¨ Features
π― Basic Monitoring
- Automatic notifications for joining, leaving, and changing voice channels (except excluded channel)
- Status monitoring (online, idle, do not disturb, offline)
- Platform detection (Mobile/Desktop) for joins and leaves
- Beautiful messages using embeds and emojis
- Data persistence in MongoDB
π Rankings and Achievements System
- Automatic achievements based on online time, voice activity, and engagement
- Competitive rankings of the most active members
- Achievement notifications when unlocked
- Medals and badges for different types of activity
π Advanced Commands
- β Detailed personal statistics
!stats
- β Ranking of the 10 most active members
!top
- β Ranking of those who used voice the most
!top voice
- β Your achievements
!achievements
- β Compare users
!compare @user1 @user2
- β General server statistics
!serverstats
- β Clear all messages from the current channel (requires permission)
!clear
- β Shows a tutorial on how to mute the channel manually in Discord (via DM)
!silence
- β List of commands
!help
β οΈ Alerts and Reminders
- Inactivity alerts for absent members
- Automatic notifications for inactive users
- Flexible configuration of days for alerts
π Silence System
- User-controlled notifications - Users can silence bot notifications
- Flexible duration - Temporary (hours/days) or permanent silence
- Automatic expiration - Temporary silences expire automatically
- Permission-based access - Requires "Manage Messages" permission
π Automatic Reports
- Weekly reports with general statistics
- Top users of the week
- Server activity rate
- Achievements granted in the period
- Automatic scheduling (Sunday at 8 PM)
π€ Sleep Mode
- β Puts the bot to sleep until it receives
!sleep
.!wake
- /
!sleep 30m
/!sleep 2h
β Bot sleeps for the specified time (minutes, hours, days).!sleep 1d
- β Wakes the bot up immediately.
!wake
- β Shows the current sleep mode status.
!status-sleep
While sleeping:
- The bot continues collecting all metrics normally (presence, voice, messages, achievements, etc).
- The bot does not send automatic messages (reports, alerts, unlocked achievements, etc).
- The bot still responds to commands.
Silence Commands:
- β Shows a tutorial on how to mute the channel manually in Discord (via DM).
!silence
The !silence command only teaches you how to mute the channel manually. The bot cannot mute channels for you, as this is a personal Discord setting.
Ranking Commands:
- β Ranking of the 10 members with the most online time
!top
- β Ranking of the 10 members with the most time in voice channels
!top voice
Achievement Commands:
- β Shows your unlocked achievements
!achievements
- β Shows achievements of another user
!achievements @user
- β Shows all achievement categories and how many there are in each (dare to collect them all!)
!achievements-categories
Achievement Categories (Examples):
- π€ Voice & Presence β For the most sociable! (e.g., stay 24h in voice?)
- π¬ Messages & Reactions β For the most active! (1000 messages in a day?)
- π¦ Social & Community β For the most popular! (help 50 people?)
- π Engagement & Usage β For the most dedicated! (7 days online without a break?)
- β° Activity & Consistency β For the most persistent! (30 days in a row?)
- π² Fun & Extras β For the most creative! (use all custom emojis?)
- π Discord Lunatic β For the craziest! (online at dawn?)
Unlock all 50 achievements and become a Discord legend! Less than 1% can do it... Will you?
Comparison Commands:
- β Compares statistics of two users
!compare @user1 @user2
Server Commands:
- β General server statistics
!serverstats
Silence System Examples:
Temporary Silence:
- β Silence notifications for 2 hours
!silence_2h
- β Silence notifications for 1 day
!silence_1d
- β Silence notifications for 1 week
!silence_7d
Permanent Silence:
- β Permanently silence all bot notifications
!silence_always
Management:
- β Check current silence status
!silence_status
- β Remove silence and resume notifications
!silence_remove
π Installation
Option 1: Docker (Recommended)
The easiest way to run Spy Bot is using Docker Compose, which includes MongoDB:
-
Clone the repository:
git clone <repository-url> cd spy-bot
-
Configure the
file:.env
-
Copy the example:
cp env.example .env
-
Fill in with your bot token, notification channel ID, and MongoDB credentials.
-
-
Run with Docker Compose:
docker-compose up -d
This will start both the bot and MongoDB automatically.
Option 2: Manual Installation
-
Clone the repository:
git clone <repository-url> cd spy-bot
-
Create the virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure the
file:.env
-
Copy the example:
cp env.example .env
-
Fill in with your bot token, notification channel ID, and MongoDB connection string.
β οΈ Important: If you're using
to load variables, make sure values with spaces are in quotes in theexport $(grep -v '^#' .env | xargs)
file:.env
# Correct (with quotes) REPORT_TIME="sunday 20:00" # Incorrect (without quotes) REPORT_TIME=sunday 20:00
-
-
Run the bot:
python main.py
βοΈ .env
Configuration
.env
For Docker Installation:
# Required Settings DISCORD_BOT_TOKEN=your_token_here CANAL_DE_NOTIFICACAO_ID=1234567890123456789 # MongoDB Settings (for Docker) MONGO_INITDB_ROOT_USERNAME=admin MONGO_INITDB_ROOT_PASSWORD=password123 MONGO_INITDB_DATABASE=spy MONGODB_URI=mongodb://admin:password123@alert-mongo:27017/spy?authSource=admin # Optional Settings SALA_EXCLUIDA=VACA WORK OS BRABO CANAL_RELATORIOS_ID=1234567890123456789 CANAL_ALERTAS_ID=1234567890123456789 REPORT_TIME=sunday 20:00 ALERT_INACTIVE_DAYS=7
For Manual Installation:
# Required Settings DISCORD_BOT_TOKEN=your_token_here CANAL_DE_NOTIFICACAO_ID=1234567890123456789 MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority # Optional Settings SALA_EXCLUIDA=VACA WORK OS BRABO CANAL_RELATORIOS_ID=1234567890123456789 CANAL_ALERTAS_ID=1234567890123456789 REPORT_TIME=sunday 20:00 ALERT_INACTIVE_DAYS=7
Required Settings:
- DISCORD_BOT_TOKEN: Your bot token from Discord Developer Portal
- CANAL_DE_NOTIFICACAO_ID: ID of the channel where notifications will be sent
- MONGODB_URI: MongoDB connection URI (for manual installation)
Docker-specific Settings:
- MONGO_INITDB_ROOT_USERNAME: MongoDB root username (for Docker)
- MONGO_INITDB_ROOT_PASSWORD: MongoDB root password (for Docker)
- MONGO_INITDB_DATABASE: MongoDB database name (for Docker)
Optional Settings:
- SALA_EXCLUIDA: Name of the voice channel that will be ignored by monitoring
- CANAL_RELATORIOS_ID: ID of the channel where weekly reports will be sent
- CANAL_ALERTAS_ID: ID of the channel where inactivity alerts will be sent
- REPORT_TIME: Time for sending the weekly report (default: "sunday 20:00")
- ALERT_INACTIVE_DAYS: Number of days to consider a user inactive (default: 7)
πΉοΈ Commands
Basic Commands:
- β Shows your statistics of time in status and voice channels
!stats
- β Clear all messages from the current channel (requires "Manage Messages" permission)
!clear
- β List of all available commands
!help
Silence Commands:
- β Shows a tutorial on how to mute the channel manually in Discord (via DM).
!silence
The !silence command only teaches you how to mute the channel manually. The bot cannot mute channels for you, as this is a personal Discord setting.
Ranking Commands:
- β Ranking of the 10 members with the most online time
!top
- β Ranking of the 10 members with the most time in voice channels
!top voice
Achievement Commands:
- β Shows your unlocked achievements
!achievements
- β Shows achievements of another user
!achievements @user
- β Shows all achievement categories and how many there are in each (dare to collect them all!)
!achievements-categories
Achievement Categories (Examples):
- π€ Voice & Presence β For the most sociable! (e.g., stay 24h in voice?)
- π¬ Messages & Reactions β For the most active! (1000 messages in a day?)
- π¦ Social & Community β For the most popular! (help 50 people?)
- π Engagement & Usage β For the most dedicated! (7 days online without a break?)
- β° Activity & Consistency β For the most persistent! (30 days in a row?)
- π² Fun & Extras β For the most creative! (use all custom emojis?)
- π Discord Lunatic β For the craziest! (online at dawn?)
Unlock all 50 achievements and become a Discord legend! Less than 1% can do it... Will you?
Comparison Commands:
- β Compares statistics of two users
!compare @user1 @user2
Server Commands:
- β General server statistics
!serverstats
Silence System Examples:
Temporary Silence:
- β Silence notifications for 2 hours
!silence_2h
- β Silence notifications for 1 day
!silence_1d
- β Silence notifications for 1 week
!silence_7d
Permanent Silence:
- β Permanently silence all bot notifications
!silence_always
Management:
- β Check current silence status
!silence_status
- β Remove silence and resume notifications
!silence_remove
π¦ Dependencies
Core Dependencies:
- - Discord API wrapper
discord.py>=2.0.0
- - Environment variable management
python-dotenv>=0.19.0
- - MongoDB driver
pymongo>=4.0.0
Development Dependencies:
- - Code formatter
black>=23.0.0
- - Linter
flake8>=6.0.0
- - Import sorter
isort>=5.12.0
- - Security linter
bandit>=1.7.5
- - Git hooks
pre-commit>=3.0.0
Installation:
# Production dependencies pip install -r requirements.txt # Development dependencies pip install -e .[dev]
π‘ Usage Example
Automatic Notifications:
- The bot sends automatic and beautiful messages when joining/leaving/changing voice channels:
Personal Statistics:
- Use to see your online time, idle time, time in each channel, etc.:
!stats
Achievement System:
- β° First Hour β Stayed online for 1 hour
- π₯ Dedicated β Stayed online for 10 hours
- π Veteran β Stayed online for 50 hours
- π€ Voice Explorer β Spent 1 hour in voice channels
- π΅ Voice Master β Spent 10 hours in voice channels
- π¦ Social Butterfly β Visited 3 different channels
- π Channel Explorer β Visited 10 different channels
Weekly Reports:
- Automatically sent every Sunday at 8 PM
- Include top users, general statistics, and weekly achievements
π‘οΈ Security
- Never share your !
.env
- The file and sensitive data are in
.env
..gitignore
π§ Troubleshooting
Environment variables problem:
If you get the error
export: not an identifier
.env
-
Use quotes in the
file:.env
REPORT_TIME="sunday 20:00"
-
Or use python-dotenv (recommended):
from dotenv import load_dotenv load_dotenv()
-
Or load manually:
source .env
Bot doesn't respond to commands:
- Check if the bot has permission to read messages
- Confirm that is enabled in the Discord Developer Portal
MESSAGE_CONTENT_INTENT
Reports are not sent:
- Check if is configured correctly
CANAL_RELATORIOS_ID
- Confirm that the bot has permission to send messages in the channel
Docker issues:
- MongoDB connection failure: Check if the MongoDB container is running with
docker-compose ps
- Bot doesn't start: Check logs with
docker-compose logs alert-bot
- Environment variables not loaded: Make sure the file exists and has correct format
.env
- Port conflicts: Change MongoDB port in if 27843 is already in use
docker-compose.yml