DEV Community

Andres David Rincon Salazar
Andres David Rincon Salazar

Posted on

I Built a Discord Automation Bot (And Why You Probably Shouldn't Use It)

⚠️ Important Disclaimer Up Front

Before we dive in, let's be crystal clear: This project violates Discord's Terms of Service. I built this purely for educational purposes to explore the technical challenges of automation detection and human behavior simulation.

Do not use this on your main Discord account. You will get banned. Permanently.

Now that we've got that out of the way, let's talk about what I learned building this.


🎯 The Problem I Was Exploring

Discord has economy bots where users can execute commands like ;work, ;farm, or ;fish to earn virtual currency. These commands need to be repeated hundreds of times, which is tedious. I wondered: How would someone automate this, and more importantly, how does Discord detect automation?

This led me down a rabbit hole of studying:

  • Human behavior patterns
  • Timing randomization techniques
  • Discord's API and detection mechanisms
  • Anti-bot strategies

🛠️ Technical Architecture

The Core Challenge: Looking Human

The biggest challenge wasn't making a bot that sends messages—that's trivial. The challenge was making it look human enough to avoid immediate detection.

Here's what I implemented:

1. Random Timing Patterns

MIN_DELAY = 0        # Minimum delay in seconds
MAX_DELAY = 5        # Maximum delay in seconds
JITTER = 3           # Additional random variation (±)

# Calculate next execution time
baseDelay = random.uniform(MIN_DELAY, MAX_DELAY)
jitteredDelay = baseDelay + random.uniform(-JITTER, JITTER)
Enter fullscreen mode Exit fullscreen mode

Humans don't click buttons at exact intervals. We're inconsistent. The bot uses three layers of randomization:

  • Base random delay between min and max
  • Additional jitter for natural variation
  • Occasional complete breaks (more on this below)

2. Typing Indicators

# Simulate human typing behavior
humanTypingDelay = random.uniform(0.5, 2.0)
await asyncio.sleep(humanTypingDelay)

# Show typing indicator
async with self.targetChannel.typing():
    typingStatusDuration = random.uniform(0.5, 1.5)
    await asyncio.sleep(typingStatusDuration)

await self.targetChannel.send(';work')
Enter fullscreen mode Exit fullscreen mode

Real users don't instantly send messages. There's a brief pause while typing, and Discord shows the "typing..." indicator. The bot simulates this with random delays and proper typing indicators.

3. Random Breaks

# 5% chance of taking a break
if random.random() < 0.05:
    breakDuration = random.uniform(120, 180)  # 2-3 minutes
    print(f'Taking a break ({breakDuration:.0f}s)')
    await asyncio.sleep(breakDuration)
    continue
Enter fullscreen mode Exit fullscreen mode

Humans don't grind endlessly. We get distracted, check our phones, grab snacks. The bot randomly takes 2-3 minute breaks with a 5% probability to simulate natural behavior.

4. Initial Delay

# Don't start immediately after connecting
initialWaitTime = random.uniform(2, 8)
print(f'Waiting {initialWaitTime:.1f}s before starting...')
await asyncio.sleep(initialWaitTime)
Enter fullscreen mode Exit fullscreen mode

When humans open Discord, they don't immediately start typing. The bot waits a few seconds after connecting to appear more natural.


🔍 What I Learned About Detection

Through research and experimentation, I discovered several ways Discord likely detects automation:

1. Timing Patterns

  • Perfect intervals are a dead giveaway
  • Too fast = instant red flag
  • Too consistent = suspicious pattern

2. User Token Usage

  • User accounts automating actions are explicitly against ToS
  • Discord actively monitors for user token automation
  • Bot accounts should be used instead (but can't execute user commands)

3. Behavioral Analysis

  • No typing indicators = suspicious
  • Instant responses = bot-like
  • Never taking breaks = inhuman
  • Consistent message length/format = automated

4. Rate Limiting

  • Discord has built-in rate limits
  • Exceeding them flags your account
  • Even "human-like" bots can get caught here

📊 The Architecture

class DiscordCommandAutomation(discord.Client):
    def __init__(self, channelId):
        # Initialize with minimal intents for stealth
        intents = discord.Intents.default()
        intents.message_content = False
        intents.guilds = True
        super().__init__(intents=intents)

        self.targetChannelId = channelId
        self.targetChannel = None
Enter fullscreen mode Exit fullscreen mode

I used discord.py with minimal intents to reduce the bot's footprint. The fewer permissions requested, the less suspicious it appears.


🚫 Why This Violates Discord's ToS

Let's be explicit about what rules this breaks:

  1. Automated User Actions: Discord prohibits automating actions from user accounts
  2. Self-botting: Using your user token for automation is called "self-botting" and is banned
  3. Evasion Attempts: The human-simulation features are explicitly trying to evade detection
  4. Mass Messaging: Even to a single channel, automated messages violate ToS

Consequences:

  • Permanent account ban
  • Loss of all servers, DMs, and purchased content
  • IP bans in severe cases
  • No appeals process

🎓 Educational Takeaways

What I Learned About Bot Detection

  1. Randomization isn't enough: Even with heavy randomization, sophisticated systems can detect patterns over time

  2. Metadata matters: Things like typing indicators, read receipts, and connection patterns all factor into detection

  3. Statistical analysis wins: Over enough samples, automated behavior creates statistical signatures that differ from human behavior

  4. The arms race is real: Detection systems evolve constantly, requiring automation to evolve too

What I Learned About Python

  1. Async programming: Discord.py relies heavily on asyncio, which was great practice
  2. Rate limiting: Implementing respectful rate limiting is crucial
  3. Error handling: Network issues, API changes, and edge cases require robust error handling

🔧 Technical Challenges I Faced

Challenge 1: Token Extraction

Getting a user token requires browser inspection, which felt sketchy (because it is). I intentionally left detailed instructions out of the README for ethical reasons.

Challenge 2: Timing Perfection

Finding the sweet spot between "too fast" (obvious bot) and "too slow" (defeats the purpose) required extensive testing and adjustment.

Challenge 3: Discord.py Changes

The library has breaking changes between versions. Maintaining compatibility was tricky.

Challenge 4: Ethical Documentation

How do you document something educational that's also potentially harmful? I erred on the side of over-warning users.


💭 Reflection: Should I Have Built This?

The case for:

  • Educational value in understanding automation detection
  • Demonstrates important security concepts
  • Provides a case study in ToS violations
  • Shows Python async programming patterns

The case against:

  • Could enable ToS violations
  • Might lead to account bans for uninformed users
  • Contributes to the automation arms race
  • Potentially harmful to Discord's ecosystem

I chose to publish it with extensive warnings because I believe in transparent education. But I've made it clear: don't actually use this.


🔗 The Code

You can find the full project here: github.com/1594-adrs/discord-bots-automation

Key features:

  • ✅ Random timing with jitter
  • ✅ Typing indicators
  • ✅ Random breaks
  • ✅ Human behavior simulation
  • ✅ Extensive documentation
  • ⚠️ Will get you banned

🎯 Alternatives (Legal Ones)

If you actually want to automate Discord tasks legally:

  1. Use Official Bot Accounts: Create a proper Discord bot application
  2. Discord.js/Discord.py: Build bots that follow ToS
  3. Webhooks: Use Discord webhooks for automated messages
  4. Official APIs: Leverage Discord's official automation features

📚 What's Next?

I'm not planning to maintain or expand this project. It served its educational purpose.

Instead, I'm focusing on other personal projects.


💬 Discussion Questions

I'd love to hear your thoughts:

  1. Is publishing automation tools that violate ToS ethical if clearly labeled educational?
  2. What other approaches could make automation detection more difficult?
  3. Have you built automation tools that violated a platform's ToS? What did you learn?
  4. Where's the line between automation and abuse?

🙏 Final Thoughts

This project taught me more about what not to do than what to do. Sometimes the best way to learn about security is to understand how it can be circumvented—not to circumvent it, but to defend against it.

If you're building automation tools, do it the right way. Use official APIs, follow ToS, and respect the platforms you build on.

And if you're thinking about using this bot on your main Discord account? Don't.


GitHub: 1594-adrs/discord-bots-automation


Top comments (0)