ScamGuard watches your server for the same image posted across multiple channels at once β the #1 sign of a coordinated scam raid. When detected, it deletes every copy and times out the user automatically.
| Cross-channel detection | Catches the same file uploaded to 3+ channels within 60 seconds |
| URL & embed detection | Also detects image links pasted as text or shared via link preview |
| Instant deletion | Every spam message is removed on arrival, including ones sent after the trigger |
| Auto timeout | Spammer receives a 10-minute timeout the moment spam is confirmed |
| Moderation alerts | Posts a summary to your log channel listing the user and affected channels |
| Zero false positives | Only fires when the same key appears in 3+ different channels β never for single-channel posts |
| Lightweight | No database, no external services β runs entirely in memory |
Don't want to host it yourself? Invite the public version directly to your server with one click:
To self-host, you need:
- Bun v1.0+
- A Discord bot with these permissions:
Manage Messagesβ to delete spamModerate Membersβ to timeout usersRead Message HistorySend Messagesβ for log channel alerts
- These Privileged Gateway Intents enabled in the Developer Portal:
Server Members IntentMessage Content Intent
git clone https://github.com/robticorg/scam-guard.git
cd scam-guardbun installcp .env.example .envOpen .env and fill in:
| Variable | Required | Description |
|---|---|---|
TOKEN |
Yes | Bot token from the Discord Developer Portal |
LOG_CHANNEL_ID |
No | Channel ID for moderation alerts. Leave empty to disable. |
See .env.example for the full variable list including test variables.
In the Developer Portal, generate an invite URL with:
- Scope:
bot - Permissions:
Manage Messages,Moderate Members,Read Message History,Send Messages
Enable these under Privileged Gateway Intents:
# Production
bun run start
# Development β auto-restarts on file changes
bun run dev
# Development with full debug logging
DEBUG=1 bun run devOn startup you will see:
[ScamGuard] online as ScamGuard#0000 (bot-id)
[ScamGuard] watching 1 guild(s)
Coming soon β a full walkthrough covering bot creation, permissions, and
.envsetup.Subscribe or join our Discord to be notified when it's live.
- A user posts an image (file upload, CDN URL, or link preview) in a channel.
- ScamGuard records the image key, user, channel, and timestamp.
- When the same key appears in 3+ different channels within 60 seconds, spam is confirmed.
- The triggering message is deleted instantly. All previous copies are deleted and the user is timed out.
- Any messages posted after the threshold is crossed are also deleted on arrival.
All values are in src/config/constant.ts:
| Constant | Default | Description |
|---|---|---|
CHANNEL_THRESHOLD |
3 |
Unique channels needed to trigger |
WINDOW_MS |
60 000 ms |
Rolling time window |
TIMEOUT_MS |
600 000 ms |
Duration of the user timeout (10 min) |
The test suite runs a real "spammer" bot against a live guild where ScamGuard is active.
SPAMMER_TOKEN=your_spammer_bot_token
TEST_GUILD_ID=your_guild_id
TEST_CHANNEL_IDS=channel1,channel2,channel3,channel4
ALLOW_BOT_MESSAGES=1ALLOW_BOT_MESSAGES=1 bun run devbun run test # standard
bun run test:debug # with full debug output| # | Scenario | Expected |
|---|---|---|
| 1 | Same image β 3 channels | Deleted + user timed out |
| 2 | Same image β 2 channels | No action |
| 3 | Different images β 3 channels | No action |
| 4 | Text only β 3 channels | No action |
| 5 | Step-by-step 1 β 2 β 3 | Fires exactly on the 3rd channel |
src/
βββ index.ts # Entry point
βββ messageCreate.ts # Message listener β tracks and triggers
βββ detector.ts # isSpam() logic
βββ tracker.ts # In-memory record store
βββ types.d.ts # Shared types
βββ actions/
β βββ handleSpam.ts # Orchestrates delete + timeout + alert
β βββ deleteMessages.ts # Deletes spam messages
β βββ timeoutUser.ts # Times out the spammer
β βββ sendAlert.ts # Posts to log channel
βββ config/
β βββ constant.ts # Thresholds and timing
β βββ store.ts # Shared state
βββ utils/
βββ getAttachmentKey.ts # Extracts key from file, URL, or embed
βββ debug.ts # Logger (controlled by DEBUG env var)
test/
βββ spam.spec.ts # Live integration tests
Having trouble setting up or configuring ScamGuard?
- Email: contact@robtic.org
- Discord: discord.gg/3vfqhtgZM5
We're happy to help with bot permissions, hosting, and configuration questions.
MIT Β©2026 Robtic Org


