Major Domo v2 - Discord bot for Strat-o-Matic Baseball Association
Go to file
Cal Corum bf374c1b98 CLAUDE: Fix /set-image command to use query parameters for API updates
The /set-image command was failing to persist player image updates to the
database. Investigation revealed a mismatch between how the bot sent PATCH
data versus how the database API expected it.

Root Cause:
- Database API endpoint (/api/v3/players/{id}) expects PATCH data as URL
  query parameters, not JSON body
- Bot was sending: PATCH /api/v3/players/12288 {"vanity_card": "url"}
- API expected: PATCH /api/v3/players/12288?vanity_card=url

Changes Made:

1. api/client.py:
   - Added use_query_params parameter to patch() method
   - When enabled, sends data as URL query parameters instead of JSON body
   - Maintains backward compatibility (defaults to JSON body)

2. services/base_service.py:
   - Added use_query_params parameter to patch() method
   - Passes parameter through to API client

3. services/player_service.py:
   - Updated update_player() to use use_query_params=True
   - Added documentation note about query parameter requirement

4. commands/profile/images.py:
   - Fixed autocomplete to use correct utility function
   - Changed from non-existent player_autocomplete_with_team_priority
   - Now uses player_autocomplete from utils/autocomplete.py

Documentation Updates:

5. commands/profile/README.md:
   - Updated API Integration section
   - Documented PATCH endpoint uses query parameters
   - Added note about automatic handling in player_service

6. services/README.md:
   - Added PATCH vs PUT operations documentation
   - Documented use_query_params parameter
   - Included usage examples for both modes

Testing:
- Verified /set-image command now successfully persists image URLs
- Confirmed API returns updated player with vanity_card populated
- Validated both fancy-card and headshot updates work correctly

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-13 17:52:14 -05:00
api CLAUDE: Fix /set-image command to use query parameters for API updates 2025-10-13 17:52:14 -05:00
commands CLAUDE: Fix /set-image command to use query parameters for API updates 2025-10-13 17:52:14 -05:00
models CLAUDE: Implement custom help commands system 2025-10-10 13:14:13 -05:00
services CLAUDE: Fix /set-image command to use query parameters for API updates 2025-10-13 17:52:14 -05:00
tasks CLAUDE: Comprehensive bot improvements and test infrastructure 2025-10-02 11:35:26 -05:00
tests CLAUDE: Implement player image management system 2025-10-10 13:54:12 -05:00
utils CLAUDE: Fix trade system issues and enhance documentation 2025-10-06 16:10:13 -05:00
views CLAUDE: Implement custom help commands system 2025-10-10 13:14:13 -05:00
.gitignore CLAUDE: Initial commit for discord-app-v2 rebuild 2025-08-15 00:04:50 -05:00
bot.py CLAUDE: Implement player image management system 2025-10-10 13:54:12 -05:00
config.py CLAUDE: Major bot enhancements - Admin commands, player stats, standings, schedules 2025-08-28 15:32:38 -05:00
constants.py CLAUDE: Implement custom help commands system 2025-10-10 13:14:13 -05:00
exceptions.py CLAUDE: Initial commit for discord-app-v2 rebuild 2025-08-15 00:04:50 -05:00
PRE_LAUNCH_ROADMAP.md CLAUDE: Implement player image management system 2025-10-10 13:54:12 -05:00
requirements.txt CLAUDE: Major bot enhancements - Admin commands, player stats, standings, schedules 2025-08-28 15:32:38 -05:00
test_real_data.py CLAUDE: Major bot enhancements - Admin commands, player stats, standings, schedules 2025-08-28 15:32:38 -05:00