ZMN Bot التوثيق
أدلة الإعداد ومرجع الضبط لكل وحدات زمن — الحماية، الإشراف، الأدوار، المستويات، والتحكم بالوصول.
تنقل سريع
وحدة الأمان
حماية متقدمة من التدمير ومراقبة التهديدات في الوقت الفعلي
نظرة عامة
توفر وحدة الأمان حماية شاملة ضد الهجمات الخبيثة والغارات والإجراءات غير المصرح بها. تستخدم المراقبة في الوقت الفعلي مع تحديد المعدل المستند إلى Redis للكشف عن التهديدات والاستجابة لها خلال أجزاء من الثانية.
الحماية ضد:
- • حظر جماعي، طرد، وحذف الرتب
- • إضافة بوتات غير مصرح بها
- • منح رتب المشرف والصلاحيات الخطيرة
- • تخريب الخادم (الاسم، الأيقونة، تغييرات الرابط)
- • رسائل القنوات/الرتب المزعجة/المحذوفة
- • رسائل الإشارة الجماعية المزعجة
الميزات الرئيسية
الكشف في الوقت الفعلي
مراقبة جميع الإجراءات الإدارية بوقت استجابة أقل من الثانية
تحديد المعدل
عدادات Redis المستندة تتبع الإجراءات خلال نوافذ 60 ثانية
العقاب الفوري
يحظر تلقائياً أو يطرد أو يزيل الرتب عند اكتشاف التهديدات
نظام التجاوز
الرتب الموثوقة يمكنها تجاوز فحوص الأمان
تنبيهات التنبيه
يرسل رسائل DM إلى الرتب المحددة عند حدوث أحداث الأمان
تسجيل مفصل
سجلات شاملة بمعلومات المنفذ والإجراءات المتخذة والطوابع الزمنية
How It Works
1Event Detection
The bot monitors Discord audit logs and events in real-time, detecting administrative actions like bans, kicks, role changes, and server modifications.
2Bypass Check
Before taking action, the bot checks if the executor has a bypass role. Trusted administrators can be whitelisted to prevent false positives.
3Rate Limit Check
For limit-based protections, the bot increments a Redis counter and checks if the configured limit has been exceeded within a 60-second window.
4Punishment & Logging
If a threat is detected, the configured punishment is applied (ban, kick, or clear roles). A detailed log is sent to the log channel and alert roles are notified via DM.
Protection Types
Anti-Nuke Limits (Rate-Based)
These protections trigger when a user performs too many actions within 60 seconds. Each has a configurable limit and action.
Mass Bans
Detects excessive member bans
Mass Kicks
Detects excessive member kicks
Role Creation
Detects rapid role creation
Role Deletion
Detects mass role deletions
Channel Creation
Detects rapid channel creation
Channel Deletion
Detects mass channel deletions
Mass Mentions
Detects spam mentions (@everyone, @here, role mentions)
Anti-Nuke Instant (Immediate Response)
These protections trigger immediately on the first occurrence. No rate limiting - instant punishment.
Bot Addition
Triggers when any bot is added to the server
Admin Role Grant
Triggers when admin role is given to a member
Dangerous Permissions
Triggers when dangerous permissions are granted
Member Prune
Triggers on server member prune actions
Vanity URL Change
Triggers when server vanity URL is changed
Server Rename
Triggers when server name is changed
Server Icon Change
Triggers when server icon is changed
Role Rename
Triggers when a role is renamed
Channel Rename
Triggers when a channel is renamed
Emoji Deletion
Triggers when server emojis are deleted
Emoji Rename
Triggers when server emojis are renamed
Invite Deletion
Triggers when server invites are deleted
Punishment Actions
When a threat is detected, you can configure one of three punishment types:
Ban
Permanently bans the offending user from the server. This is the most severe action.
Kick
Removes the user from the server. They can rejoin with a new invite.
Clear Roles
Removes all dangerous roles (Administrator and MANAGE_* permissions) from the user. They remain in the server but lose privileges.
Configuration
General Settings
Alert Roles
rolesRoles that receive DM notifications when security events occur
Bypass Roles
rolesTrusted roles that bypass all security checks (use carefully!)
Per-Protection Settings
Each protection type can be configured individually:
Enabled
toggleTurn this specific protection on or off
Limit (Limits Only)
numberNumber of actions allowed within 60 seconds before triggering
Action
selectPunishment to apply (ban, kick, or clear-roles)
Log Channel
channelChannel where detailed logs will be sent
Bypass System
The bypass system allows you to whitelist trusted administrators who should never trigger security protections.
How Bypass Works:
- • Users with bypass roles are completely exempt from all security checks
- • No logs are generated for their actions
- • No rate limiting counters are incremented
- • No punishments are applied
Logging & Notifications
Log Embeds Include:
- • Executor: Who performed the action (with avatar)
- • Target: Who was affected (for role grants, bans, etc.)
- • Action Type: What punishment was applied
- • Event Counter: Current count vs. limit (for rate-based)
- • Roles Added/Removed: Detailed list of role changes
- • Punishment Time: How long the punishment took to execute
- • Timestamp: When the event occurred
Alert Notifications
When alert roles are configured and enabled, members with those roles receive DMs containing the same log embed sent to the log channel.
Rate Limiting Details
The security module uses Redis for distributed rate limiting with the following characteristics:
60-Second Windows
Each action increments a counter that expires after 60 seconds. This creates rolling windows for rate limiting.
Per-User Tracking
Counters are tracked per guild, per user, per event type. Each user has independent limits.
Counter Reset
When a punishment is applied, the counter is immediately cleared to prevent double-punishment.
Warning Mode
If the limit is not exceeded, a warning log is sent (orange color) without applying punishment. This helps monitor suspicious activity.
Best Practices
✓ Recommended Setup
- • Start with conservative limits (5-10 per minute) and adjust based on your server's needs
- • Use "clear-roles" action initially to test without banning legitimate users
- • Set up separate log channels for limits and instant protections
- • Add your admin team to bypass roles to prevent false positives
- • Enable alert roles for high-priority protections (bot-add, admin-grant)
- • Test protections in a test server before enabling in production
✗ Common Mistakes
- • Setting limits too low (can trigger on legitimate bulk actions)
- • Not adding trusted admins to bypass roles
- • Using "ban" action without testing first
- • Forgetting to configure log channels (no visibility into events)
- • Enabling all protections at once without gradual rollout
Example Scenarios
Scenario 1: Mass Ban Attack
Situation: A compromised admin account starts banning members rapidly.
Detection: After 5 bans in 60 seconds, the limit is exceeded.
Action: Bot immediately bans the compromised account and logs the event.
Result: Attack stopped after 5 bans instead of potentially hundreds.
Scenario 2: Unauthorized Bot Addition
Situation: Someone adds a malicious bot to the server.
Detection: Bot-add instant protection triggers immediately.
Action: Bot clears all dangerous roles from the person who added the bot.
Result: Malicious bot is added but the attacker loses permissions to do further damage.
Scenario 3: Admin Role Self-Grant
Situation: A member gives themselves an admin role through an exploit.
Detection: Admin-grant instant protection detects the role change.
Action: Bot removes all dangerous roles from both the executor and target.
Result: Exploit is neutralized and both parties lose elevated permissions.
Technical Details
System Architecture:
- • Event Listeners: Individual event handlers for each protection type
- • Redis Storage: Distributed counters with automatic expiration
- • Audit Log Parsing: Extracts executor information from Discord audit logs
- • Permission Checking: Validates bot permissions before applying punishments
- • Fallback System: Automatically downgrades to clear-roles if ban/kick fails
- • Response Time: Typically under 200ms from detection to punishment
