P

i waana make a discord self bot in which it should detect a message from a bot Doduo :_: like this extract doduo from it and run a command @Pokétwo c doduo not doduo is just a example

P

i waana make a discord self bot in which it should detect a message from a bot Doduo :_: like this extract doduo from it and run a command @Pokétwo c doduo not doduo is just a example

Kodari AI
KodariMay 25 at 10:50 am 6,485 (v2)

I’ll create a Discord self-bot that automatically detects Pokémon spawns and catches them.

PoketwoCatcher
A Discord self-bot that automatically detects Pokémon spawns from Pokétwo bot messages, extracts the Pokémon name, and instantly sends catch commands. Features include spawn detection, name parsing from various formats, configurable response delays, and logging of all catch attempts. Works with Pokétwo's spawn notification format to automate the catching process.

Created a Discord self-bot that monitors Pokétwo spawns and automatically catches them. The bot detects messages like “Doduo :_:”, extracts the Pokémon name, and sends the catch command @Pokétwo c doduo.

Setup steps:

  1. Install dependencies: pip install -r requirements.txt

  2. Get your Discord user token (instructions in README)

  3. Add token to .env file

  4. Run: python main.py

⚠️ Important: Self-bots violate Discord ToS and can result in account bans. Use at your own risk.

P

a channel id cool terminal logging and more self commands

P

make it work like 100% with logging text and like auto catch work

The error --------------------- Self-bot is ready! Logged in as pr1yanshu__ Monitoring for Pokémon spawns in server 1505113754134904893, channel 1508465596960866395...

Poke-name message: '## :_: Doublade【:flag_de: Duokles】\n\u200e' pokemon_name: None --------------------------

📎 1 file 3,715 chars
📄
pasted-code-1779779566485.txt
txt 134 lines
▶
import discord
import os
import re
import asyncio
import time
from collections import defaultdict
from dotenv import load_dotenv

load_dotenv()

client = discord.Client(bot=False)

# ===== CONFIG =====
SERVER_ID = 1505113754134904893
CHANNEL_ID = 1508465596960866395
POKE_NAME_BOT_ID = 874910942490677270
CATCH_BOT = "<@716390085896962058> c"
DELAY = 0.5

# ===== STATE =====
caught = defaultdict(int)
spawns = 0
errors = 0
last_catch = {}

# Regex patterns for different message formats
PATTERNS = [
    r'## <:\w+:\d+>\s*([A-Za-z]+)',           # ## <:_:ID> NAME
    r'<\w+:\d+>\s*([A-Za-z]+)\s*【',           # <:_:ID> NAME【
    r'## <:\w+:\d+>\s*([A-Za-z]+)\s*【',        # ## <:_:ID> NAME【
    r'^([A-Za-z]+)\s+<:',                      # NAME <:
    r':\w+:\d+>\s*([A-Za-z]+)\s*【',          # :_:ID> NAME【
    r'<\w+:\d+>\s*([A-Za-z]+)$',              # <:_:ID> NAME (end)
    r'## <:\w+:\d+>\s+([A-Za-z]+)',           # ##  NAME
    r'>\s+([A-Za-z]+)\s*【',                   # > NAME【
]

def extract_pokemon(content):
    """Extract Pokémon name from message content"""
    for pattern in PATTERNS:
        match = re.search(pattern, content, re.IGNORECASE)
        if match:
            name = match.group(1)
            # Clean the name
            name = re.sub(r'[^a-zA-Z]', '', name)
            if len(name) >= 3 and len(name) <= 20:
                return name.lower()
    return None

@client.event
async def on_ready():
    print('=' * 50)
    print(f'BOT: {client.user}')
    print(f'SERVER: {SERVER_ID}')
    print(f'CHANNEL: {CHANNEL_ID}')
    print('=' * 50)
    print('READY! Use commands in Discord:')
    print('  -stats  : Show catch statistics')
    print('  -ping  : Test bot')
    print('=' * 50)

@client.event
async def on_message(message):
    global spawns, errors, last_catch
    
    # Filter messages
    if message.author.id == client.user.id:
        return
    if message.guild and message.guild.id != SERVER_ID:
        return
    if message.channel.id != CHANNEL_ID:
        return
    
    # Commands
    if message.content.startswith('-stats'):
        total = sum(caught.values())
        await message.channel.send(
            f'📊 **Stats**\n'
            f'• Spawns: {spawns}\n'
            f'• Caught: {total}\n'
            f'• Errors: {errors}'
        )
        return
    
    if message.content == '-ping':
        await message.reply('Pong! 🏓')
        return
    
    # Only process Poke-Name bot
    if message.author.id != POKE_NAME_BOT_ID:
        return
    
    content = message.content
    spawns += 1
    
    name = extract_pokemon(content)
    
    if not name:
        print(f'[SKIP] No name found in: {content[:50]}')
        return
    
    # Anti-spam: don't catch same pokemon within 5 seconds
    if name in last_catch and time.time() - last_catch[name] < 5:
        print(f'[SKIP] {name} recently caught')
        return
    
    print(f'[SPAWN] {name}')
    
    await asyncio.sleep(DELAY)
    
    try:
        await message.channel.send(f'{CATCH_BOT} {name}')
        caught[name] += 1
        last_catch[name] = time.time()
        print(f'[SENT] Catch: {name}')
    except Exception as e:
        errors += 1
        print(f'[ERROR] {e}')

# Add presence
@client.event
async def on_ready():
    await client.change_presence(
        activity=discord.Activity(
            name='Poké-Two',
            type=discord.ActivityType.watching
        )
    )
    print('=' * 50)
    print(f'BOT: {client.user}')
    print(f'CHANNEL: {CHANNEL_ID}')
    print('=' * 50)

client.run(os.getenv('DISCORD_TOKEN'))
Kodari can make mistakes. Review important code before using.
Files
.gitignore
main.py
README.md
requirements.txt
Code
4 152
main.py
import discord
import os
import re
import asyncio
from dotenv import load_dotenv

load_dotenv()

client = discord.Client()

# Configuration
POKETWO_BOT_ID = 716390085896962058  # Official Pokétwo bot ID
CATCH_COMMAND_PREFIX = "<@716390085896962058> c"  # @Pokétwo c
DELAY_SECONDS = 0.5  # Delay before catching (to avoid spam detection)

@client.event
async def on_ready():
    print(f'Self-bot is ready! Logged in as {client.user}')
    print(f'Monitoring for Pokémon spawns...')

@client.event
async def on_message(message):
    # Ignore our own messages
    if message.author.id == client.user.id:
        return
    
    # Check if message is from Pokétwo bot
    if message.author.id != POKETWO_BOT_ID:
        return
    
    # Check if message contains embeds (Pokémon spawns usually have embeds)
    if message.embeds:
        embed = message.embeds[0]
        
        # Check if it's a spawn message (usually contains "wild pokémon" or similar)
        if embed.title and "wild" in embed.title.lower():
            # Try to extract Pokémon name from embed description or title
            pokemon_name = extract_pokemon_name(embed)
            
            if pokemon_name:
                print(f'Detected spawn: {pokemon_name}')
                await asyncio.sleep(DELAY_SECONDS)
                await message.channel.send(f'{CATCH_COMMAND_PREFIX} {pokemon_name}')
                print(f'Sent catch command for: {pokemon_name}')
    
    # Also check plain text messages (if spawn format is different)
    if message.content:
        # Look for pattern like "Doduo :_:" or similar
        pokemon_name = extract_from_text(message.content)
        
        if pokemon_name:
            print(f'Detected spawn in text: {pokemon_name}')
            await asyncio.sleep(DELAY_SECONDS)
            await message.channel.send(f'{CATCH_COMMAND_PREFIX} {pokemon_name}')
            print(f'Sent catch command for: {pokemon_name}')

def extract_pokemon_name(embed):
    """Extract Pokémon name from embed"""
    # Try from description first
    if embed.description:
        # Pattern: "Doduo :_:" or "A wild Doduo appeared!"
        match = re.search(r'(\w+)\s*:_:', embed.description)
        if match:
            return match.group(1).lower()
        
        match = re.search(r'wild\s+(\w+)', embed.description, re.IGNORECASE)
        if match:
            return match.group(1).lower()
    
    # Try from title
    if embed.title:
        match = re.search(r'wild\s+(\w+)', embed.title, re.IGNORECASE)
        if match:
            return match.group(1).lower()
    
    return None

def extract_from_text(text):
    """Extract Pokémon name from plain text message"""
    # Pattern: "Doduo :_:" or similar formats
    match = re.search(r'(\w+)\s*:_:', text)
    if match:
        return match.group(1).lower()
    
    # Pattern: "A wild Doduo appeared!"
    match = re.search(r'wild\s+(\w+)', text, re.IGNORECASE)
    if match:
        return match.group(1).lower()
    
    return None

# Run the self-bot
client.run(os.getenv('DISCORD_TOKEN'), bot=False)