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
!statsβ Detailed personal statistics!topβ Ranking of the 10 most active members!top voiceβ Ranking of those who used voice the most!achievementsβ Your achievements!compare @user1 @user2β Compare users!serverstatsβ General server statistics!clearβ Clear all messages from the current channel (requires permission)!silenceβ Shows a tutorial on how to mute the channel manually in Discord (via DM)!helpβ List of commands
β οΈ 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
!sleepβ Puts the bot to sleep until it receives!wake.!sleep 30m/!sleep 2h/!sleep 1dβ Bot sleeps for the specified time (minutes, hours, days).!wakeβ Wakes the bot up immediately.!status-sleepβ Shows the current sleep mode status.
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:
!silenceβ Shows a tutorial on how to mute the channel manually in Discord (via DM).
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:
!topβ Ranking of the 10 members with the most online time!top voiceβ Ranking of the 10 members with the most time in voice channels
Achievement Commands:
!achievementsβ Shows your unlocked achievements!achievements @userβ Shows achievements of another user!achievements-categoriesβ Shows all achievement categories and how many there are in each (dare to collect them all!)
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:
!compare @user1 @user2β Compares statistics of two users
Server Commands:
!serverstatsβ General server statistics
Silence System Examples:
Temporary Silence:
!silence_2hβ Silence notifications for 2 hours!silence_1dβ Silence notifications for 1 day!silence_7dβ Silence notifications for 1 week
Permanent Silence:
!silence_alwaysβ Permanently silence all bot notifications
Management:
!silence_statusβ Check current silence status!silence_removeβ Remove silence and resume notifications
π 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
.envfile:-
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 -dThis 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
.envfile:-
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
export $(grep -v '^#' .env | xargs)to load variables, make sure values with spaces are in quotes in the.envfile:# Correct (with quotes) REPORT_TIME="sunday 20:00" # Incorrect (without quotes) REPORT_TIME=sunday 20:00 -
-
Run the bot:
python main.py
βοΈ .env Configuration
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:
!statsβ Shows your statistics of time in status and voice channels!clearβ Clear all messages from the current channel (requires "Manage Messages" permission)!helpβ List of all available commands
Silence Commands:
!silenceβ Shows a tutorial on how to mute the channel manually in Discord (via DM).
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:
!topβ Ranking of the 10 members with the most online time!top voiceβ Ranking of the 10 members with the most time in voice channels
Achievement Commands:
!achievementsβ Shows your unlocked achievements!achievements @userβ Shows achievements of another user!achievements-categoriesβ Shows all achievement categories and how many there are in each (dare to collect them all!)
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:
!compare @user1 @user2β Compares statistics of two users
Server Commands:
!serverstatsβ General server statistics
Silence System Examples:
Temporary Silence:
!silence_2hβ Silence notifications for 2 hours!silence_1dβ Silence notifications for 1 day!silence_7dβ Silence notifications for 1 week
Permanent Silence:
!silence_alwaysβ Permanently silence all bot notifications
Management:
!silence_statusβ Check current silence status!silence_removeβ Remove silence and resume notifications
π¦ Dependencies
Core Dependencies:
discord.py>=2.0.0- Discord API wrapperpython-dotenv>=0.19.0- Environment variable managementpymongo>=4.0.0- MongoDB driver
Development Dependencies:
black>=23.0.0- Code formatterflake8>=6.0.0- Linterisort>=5.12.0- Import sorterbandit>=1.7.5- Security linterpre-commit>=3.0.0- Git hooks
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
!statsto see your online time, idle time, time in each channel, etc.:
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
.envfile and sensitive data are in.gitignore.
π§ Troubleshooting
Environment variables problem:
If you get the error export: not an identifier when loading .env, it's because some variable contains spaces. Solutions:
-
Use quotes in the
.envfile: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
MESSAGE_CONTENT_INTENTis enabled in the Discord Developer Portal
Reports are not sent:
- Check if
CANAL_RELATORIOS_IDis configured correctly - 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
.envfile exists and has correct format - Port conflicts: Change MongoDB port in
docker-compose.ymlif 27843 is already in use