How to Use Discord Server AutoMod to Block Specific Username Patterns
🔍 WiseChecker

How to Use Discord Server AutoMod to Block Specific Username Patterns

Server owners and moderators often want to prevent users with certain username patterns from joining or participating in their Discord server. Usernames containing curse words, spam links, or impersonation attempts can disrupt community safety and increase moderation workload. Discord AutoMod provides a built-in rule system that scans usernames for specific keywords, regex patterns, or common spam formats. This article explains how to configure AutoMod rules to block username patterns that violate your server rules.

Key Takeaways: Blocking Username Patterns with Discord AutoMod

  • Server Settings > AutoMod > Add Rule: Create a new rule targeting username content with custom keywords or regex.
  • Regex patterns for username blocking: Use regular expressions to match complex patterns like “admin_123” or fake Discord staff names.
  • Automated action: Block member join: Set AutoMod to automatically block users whose username matches the rule before they enter the server.

ADVERTISEMENT

What Discord AutoMod Username Blocking Does and What You Need

Discord AutoMod is a moderation tool that automatically enforces server rules by scanning messages, member joins, and usernames. When you create a rule for username patterns, AutoMod checks the username of every new member attempting to join your server. If the username matches a keyword, phrase, or regex pattern you define, AutoMod can automatically block the user from joining or flag the username for manual review. This feature helps prevent spam bots, impersonators, and disruptive users from entering your community.

Before you start, you need the Manage Server permission and your server must have Community enabled. Community servers unlock AutoMod and other moderation features. To enable Community, go to Server Settings > Enable Community and follow the prompts. You also need a clear list of username patterns you want to block, such as words, partial strings, or regex patterns like .\badmin\b. to catch any username containing “admin”.

Steps to Create an AutoMod Rule for Username Patterns

  1. Open Server Settings
    Click your server name at the top left of the Discord window. Select Server Settings from the dropdown menu.
  2. Go to AutoMod
    In the left sidebar, scroll down to the Moderation section and click AutoMod.
  3. Click Add Rule
    On the AutoMod page, click the blue Add Rule button in the top right corner.
  4. Name Your Rule
    In the Rule Name field, enter a descriptive name, such as “Block Usernames with Curse Words” or “Block Impersonation Patterns”.
  5. Select the Trigger Type
    Under Trigger, choose Keyword if you want to block specific words or phrases. Choose Regex if you want to block complex patterns. For username blocking, keyword matching is sufficient for simple lists. Regex is better for patterns like “admin_123” where the number varies.
  6. Define the Matching Criteria
    For keyword: Enter each word or phrase on a separate line. For regex: Enter your regular expression pattern. Toggle Case sensitive if needed. Under Check against, select Username. This tells AutoMod to scan the user’s username, not their messages.
  7. Set the Action
    Under Action, choose Block member from joining to prevent the user from entering your server. Alternatively, choose Flag for review to allow the join but flag it for moderators. Blocking is recommended for clear violations.
  8. Configure Exemptions Optional
    Under Exempt Roles, add roles that should bypass this rule, such as Admin or Moderator. Under Exempt Channels, leave empty since this rule applies to usernames, not channels.
  9. Save the Rule
    Click Save at the bottom. The rule becomes active immediately. Users with matching usernames will be blocked from joining.

ADVERTISEMENT

Common Mistakes When Blocking Username Patterns

Rule Does Not Block Usernames That Contain the Pattern

If your rule uses keyword matching and the username contains the keyword as part of a larger word, AutoMod will still block it. For example, the keyword “admin” will block usernames like “admin123” and “theadmin”. If you want to block only exact matches, use regex with word boundaries: \badmin\b. This blocks “admin” but not “administrator”.

Regex Pattern Blocks Too Many Users

A poorly written regex can block legitimate usernames. For example, .test. blocks any username containing “test”, including “contest” or “testify”. Test your regex in a regex tester before adding it. Use word boundaries \b or anchors ^ and $ to limit matches.

Rule Does Not Apply to Existing Members

AutoMod username rules only apply to new members joining after the rule is created. Existing members with violating usernames are not affected. To handle existing members, you must manually rename them or use a bot that checks usernames periodically.

Blocking Prevents Legitimate Users from Joining

If your rule is too broad, it may block users with innocent usernames. For example, blocking the word “help” could block “helpfuluser123”. Use specific patterns and test with a small set of keywords first. You can also use the Flag for review action to manually approve users before blocking becomes permanent.

Discord AutoMod Rule Types: Keyword vs Regex for Username Blocking

Item Keyword Matching Regex Pattern Matching
Setup difficulty Easy — just list words or phrases Moderate — requires regex knowledge
Match flexibility Matches exact words or partial strings Supports complex patterns, word boundaries, and case sensitivity
Best for Blocking simple curse words, spam domains, or common impersonation names Blocking patterns like “admin_123”, “staff-username”, or usernames with specific character sequences
False positive risk Higher — may block legitimate usernames containing the keyword Lower — if pattern is precise
Performance impact Minimal Slightly higher but still negligible for most servers

After setting up your AutoMod rule, test it by attempting to join with a test account that has a matching username. If the rule works, the user will see a message saying they cannot join due to AutoMod settings. If it does not work, double-check that the rule is enabled, the trigger type is correct, and the action is set to Block member from joining. Adjust the keyword or regex pattern as needed.

Discord AutoMod username blocking is a powerful way to keep your server safe from spam bots, impersonators, and disruptive users. Start with a small list of keywords and expand as you see patterns in user behavior. For advanced protection, combine username rules with message content rules and manual moderation. This layered approach reduces the workload on your moderation team and maintains a positive environment for your community.

ADVERTISEMENT