A high-performance Discord security bot designed to catch and remove self-bots and malicious users who ignore server warnings. The bot monitors specific "Trap" channels and instantly bans anyone who sends a message there.
- Instant Detection โ Real-time monitoring of multiple restricted channels.
- Auto-Ban โ Immediately bans violators with zero tolerance.
- 24h Message Purge โ Automatically deletes all messages the banned user sent in the last 24 hours across the server.
- DM Notification โ Sends a notification to the user before banning (best-effort, fails silently if DMs disabled).
- MySQL Database โ Persistent ban history storage with search and statistics.
- Detailed Ban Logs โ Rich embed logs with:
- User avatar, tag, ID, and mention
- Account creation date
- Server join date
- Display name and roles
- Captured message content
- Suspicious account age warning (< 7 days old)
- Slash Commands:
/setup-trapโ Initialize trap channels/statusโ View bot uptime, statistics, and recent bans/ban-infoโ Look up ban information for a user by ID (Discord ban lookup)/bansโ Ban history from database:/bans recent [limit]โ Show recent bans/bans search <user_id>โ Search bans by user ID/bans statsโ Show database statistics
- Structured Logging โ Colored console logger with timestamps (system, security, ban, detection, command)
- Statistics Tracking โ In-memory tracking of bans, detections, and DM success rate
- Branded Design โ Custom logo and professional embeds
VoidSentry/
โโโ assets/ # Branding assets
โ โโโ logo.png
โ โโโ VoidSentryBanner.gif
โ โโโ VoidSentryLogo.gif
โโโ src/
โ โโโ config/
โ โ โโโ index.js # Environment config, MySQL settings
โ โโโ commands/
โ โ โโโ setupTrap.js # /setup-trap
โ โ โโโ status.js # /status
โ โ โโโ banInfo.js # /ban-info (Discord ban lookup)
โ โ โโโ bans.js # /bans (database history)
โ โโโ embeds/
โ โ โโโ warningEmbed.js # Trap channel warning
โ โ โโโ banLogEmbed.js # Detailed ban log
โ โ โโโ banNotificationEmbed.js # DM notification
โ โโโ events/
โ โ โโโ ready.js # Bot startup & database init
โ โ โโโ interactionCreate.js # Slash command router
โ โ โโโ messageCreate.js # Core trap detection & ban logic
โ โโโ utils/
โ โโโ db.js # MySQL database connection
โ โโโ deploy.js # Slash command deployment
โ โโโ helpers.js # Utility functions
โ โโโ logger.js # Colored console logger with timestamps
โ โโโ permissions.js # Permission checker
โ โโโ stats.js # In-memory statistics
โ โโโ constants.js # Colors, paths, branding
โโโ .env # Your secrets (not committed)
โโโ .env.example # Example config template
โโโ .gitignore
โโโ index.js # Entry point
โโโ package.json
โโโ README.md
- Requirement: Node.js v18.0 or higher.
- Database: Set up a MySQL database (see configuration below).
- Download: Clone or download this repository.
- Install Dependencies:
npm install
Copy .env.example to .env and fill in your credentials:
| Key | Description |
|---|---|
DISCORD_TOKEN |
Your bot's secret token from the Developer Portal. |
CLIENT_ID |
Your bot's Application ID. |
OWNER_ID |
Your Discord User ID (for admin commands). |
GUILD_ID |
Discord Server ID for development (guild commands). |
BAN_CHANNEL_IDS |
IDs of "Trap" channels, separated by commas. |
LOG_CHANNEL_ID |
Channel ID for ban log embeds. |
STATUS_TEXT |
Bot status text (default: Watching for breaches...). |
DELETE_MESSAGE_SECONDS |
Messages to delete on ban (default: 86400 = 24h). |
BAN_REASON |
Custom ban reason. |
NODE_ENV |
development for guild commands, production for global. |
| Key | Description | Default |
|---|---|---|
DB_HOST |
MySQL server hostname | localhost |
DB_PORT |
MySQL server port | 3306 |
DB_USER |
MySQL username | root |
DB_PASSWORD |
MySQL password | (empty) |
DB_NAME |
Database name | voidsentry |
Note: The database and table will be created automatically on first run.
-
Create Database (optional - auto-created on first run):
CREATE DATABASE voidsentry;
-
Invite the Bot: Ensure the bot has
Ban Members,Manage Messages, andView Channelspermissions. -
Role Hierarchy: Move the bot's role to the very top of your Role list.
-
Deploy Commands:
# For development (faster, guild-specific) npm run deploy:guild # For production (global commands, ~1hr propagation) npm run deploy
-
Launch:
npm start
-
Initialize: Go to each trap channel and use
/setup-trap.
| Command | Description | Permissions |
|---|---|---|
/setup-trap |
Clears channel and posts trap warning | Owner / Administrator |
/status |
Bot uptime, stats, ping, recent bans | Owner / Administrator |
/ban-info |
Look up Discord ban by user ID | Owner / Administrator |
/bans recent [limit] |
Recent bans from database | Owner / Administrator |
/bans search <user_id> |
Search database by user ID | Owner / Administrator |
/bans stats |
Database statistics | Owner / Administrator |
When a user is banned, the log embed includes:
| Field | Description |
|---|---|
| ๐ค User | Tag, ID, and mention |
| ๐ Account Created | When the Discord account was created |
| ๐ฅ Joined Server | When the user joined your server |
| ๐ท๏ธ Display Name | Server nickname or username |
| ๐ญ Roles | All roles the user had (up to 15) |
| Why the ban occurred | |
| ๐ Detected In | Which trap channel triggered the ban |
| ๐ Action Taken At | Exact timestamp of the ban |
| ๐ฌ Message Content | What the user wrote (truncated if long) |
| ๐ฉ Suspicious Flag | Warns if the account is less than 7 days old |
- ๐ Detection โ Message detected in trap channel
- ๐๏ธ Cleanup โ Trigger message immediately deleted
- โ Validation โ Bot permissions and role hierarchy checked
- ๐จ DM Notification โ User notified via DM (best-effort)
- ๐จ Ban Execution โ User banned, 24h of messages purged
- ๐พ Database โ Ban record stored in MySQL
- ๐ Stats โ Ban recorded in statistics tracker
- ๐ Logging โ Detailed embed sent to log channel
- Message Content Intent: Must be enabled in Discord Developer Portal โ Bot โ Privileged Intents.
- Database: MySQL is required for ban history storage. Database auto-creates on first run.
- No Appeals: The bot uses a "zero-tolerance" policy. Anyone typing in the trap channel is banned immediately.
- 24h Purge: All messages from the banned user in the last 24 hours are automatically deleted.
- DM Notification: Best-effort, fails silently if user has DMs disabled.
The bans table is created automatically:
CREATE TABLE bans (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id VARCHAR(20) NOT NULL,
user_tag VARCHAR(100) NOT NULL,
guild_id VARCHAR(20) NOT NULL,
guild_name VARCHAR(100) NOT NULL,
channel_id VARCHAR(20) NOT NULL,
channel_name VARCHAR(100) NOT NULL,
message_content TEXT,
reason VARCHAR(500) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_user_id (user_id),
INDEX idx_guild_id (guild_id),
INDEX idx_created_at (created_at)
);Created for secure Discord community management.
