Skip to content

[BUG] games.py update_stats() never uses bot_user_id parameter #12

@galpt

Description

@galpt

Issue

In cog/games.py lines 31-43, the update_stats() method accepts a bot_user_id parameter but it is never passed from any call site:

def update_stats(self, user_id: int, result: str, game: str = "rps", bot_user_id: int = None):
    if user_id is None or user_id == bot_user_id:  # This guard never triggers
        return
    # ...

# Call sites ([lines 117-118](https://github.com/InvalidDavid/Usagi-Bot/blob/main/cog/games.py#L117-L118), [212-213](https://github.com/InvalidDavid/Usagi-Bot/blob/main/cog/games.py#L212-L213)):
self.db.update_stats(self.p1.id, p1_result, "rps")  # No bot_user_id passed

Why This Is a Problem

The intended protection against counting bot-vs-human games is non-functional. The bot_user_id parameter is dead code.


How to Fix

Either:

  1. Remove the parameter if not needed (simpler)
  2. Pass it from call sites if you want the protection:
self.db.update_stats(self.p1.id, p1_result, "rps", bot_user_id=self.bot_user.id)

I recommend option 1 for simplicity since the current logic is broken anyway.


Severity

High - Dead parameter, potential stat corruption if bot games counted

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions