How do I stop email addresses and API keys being posted in public Discord channels?
By Wysp, Serverfront. Last checked
Short answer
Use AutoMod. In your server's AutoMod settings, create a custom keyword rule, paste a regex pattern into its regex field, and set the action to Block. Use one pattern for email addresses and one for common API keys. Test each pattern in a private channel before you turn on Block.
Where to add the rule
Open your server's AutoMod settings → create a custom keyword rule → paste the pattern into its regex field.
Limits: up to 6 keyword rules per server, and up to 10 regex patterns per rule (260 characters each).
Test each pattern in a private channel before you turn on Block.
Starter patterns
These are the same patterns as in the 20-minute checklist, which has copy buttons.
1. Email addresses
Suggested action: Block.
[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}
2. Common API keys and tokens
OpenAI-style, Stripe, GitHub, AWS and Slack. Suggested action: Block.
(sk-[A-Za-z0-9_-]{20,}|sk_(live|test)_[A-Za-z0-9]{20,}|ghp_[A-Za-z0-9]{36}|github_pat_[A-Za-z0-9_]{22,}|AKIA[0-9A-Z]{16}|xox[abprs]-[A-Za-z0-9-]{10,})
3. Phone numbers
US and international styles. Suggested action: Send alert only, because it can catch some normal numbers.
(\+\d{1,3}[\s.-]?\d{2,4}([\s.-]?\d{2,4}){2,3}|\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4})
Tell your members too
A pattern can't catch every password or secret. Add this line to your member notice:
Please never post emails, phone numbers, passwords or API keys in public channels.
Why it matters now
From mid-December 2026, text from public channels can appear on your server's page and in search engines. Support channels where people paste logs are the riskiest: logs often contain emails, file paths and API keys.
The free Serverfront Check can test your AutoMod rules with a sample email address and API key, if you give it the Manage Server permission.
Sources
- Discord developer docs: Auto Moderation (limits and actions)
- Discord blog, Oct 27, 2026: Making Content from Discoverable Servers Easier to Discover
We read these pages again on . Discord may change these details. Check the Help Center before you rely on a specific date or setting. How we check facts.