CLAUDE: Fix /reset-image AttributeError by updating owner_only function

The owner_only() function was accessing ctx.author.id, which caused an
AttributeError when called with Interaction objects from slash commands
(which use .user instead of .author).

Updated both utils.py and helpers/utils.py to handle both Context and
Interaction objects by checking for .user first, then falling back to
.author for backward compatibility with traditional commands.

Fixes: Command 'reset-image' raised an exception: AttributeError:
'Interaction' object has no attribute 'author'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2025-11-10 08:21:17 -06:00
parent c043948238
commit c0f9466e54
2 changed files with 12 additions and 6 deletions

View File

@ -94,7 +94,10 @@ def owner_only(ctx) -> bool:
# ID for discord User Cal # ID for discord User Cal
owners = [287463767924137994, 1087936030899347516] owners = [287463767924137994, 1087936030899347516]
if ctx.author.id in owners: # Handle both Context (has .author) and Interaction (has .user) objects
user = getattr(ctx, 'user', None) or getattr(ctx, 'author', None)
if user and user.id in owners:
return True return True
return False return False

View File

@ -91,7 +91,10 @@ def owner_only(ctx) -> bool:
# ID for discord User Cal # ID for discord User Cal
owners = [287463767924137994, 1087936030899347516] owners = [287463767924137994, 1087936030899347516]
if ctx.author.id in owners: # Handle both Context (has .author) and Interaction (has .user) objects
user = getattr(ctx, 'user', None) or getattr(ctx, 'author', None)
if user and user.id in owners:
return True return True
return False return False