Skip to content

[PERF] games.py asyncio.sleep(1) blocks bot during bot_move #15

@galpt

Description

@galpt

Issue

In cog/games.py#L251, the bot deliberately waits 1 second before making its move:

async def bot_move(self):
    await asyncio.sleep(1)  # Blocks for 1 second!

Why This Is a Problem

This asyncio.sleep(1) blocks the entire Discord event loop for 1 second after every player move. During this time:

  • No other commands can be processed
  • No messages can be handled
  • Users experience noticeable lag

The 1-second delay is likely meant to simulate "thinking" but it's disruptive.


How to Fix

Option 1 (recommended): Remove the sleep entirely:

async def bot_move(self):
    # Remove the sleep - bot decisions are fast

Option 2: If you want visual feedback, show "Bot is thinking..." in the embed instead of blocking:

# Edit the embed to show thinking state
await asyncio.sleep(0.5)  # Brief pause, not blocking

Severity

High - User-visible lag on every game move

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions