DMcP89 / harambot

A Yahoo Fantasy Sports bot for Discord
MIT License
29 stars 18 forks source link

Stats command fails in NHL leagues due to too many fields #173

Closed DMcP89 closed 1 month ago

DMcP89 commented 1 month ago

Describe the bug The amount of stats available in an NHL league is >25 which is the maximum amount of fields an embed can have.

To Reproduce Steps to reproduce the behavior:

  1. Configure harambot against an NHL league
  2. Run the /stats command against any player

Expected behavior The player's embed should return as normal

2024-10-09 16:01:49] [INFO    ] discord.harambot.cogs.yahoo: Command:Stats called in 536626059597185024 with player_name:Brent Burns
[2024-10-09 16:01:51] [ERROR   ] discord.app_commands.tree: Ignoring exception in command 'stats'
Traceback (most recent call last):
File "/home/dave/.pyenv/versions/harambot/lib/python3.10/site-packages/discord/app_commands/commands.py", line 857, in *do_call
return await self.callback(self.binding, interaction, **params)  # type: ignore
File "/home/dave/workspace/projects/harambot/harambot/cogs/yahoo.py", line 248, in stats
await interaction.followup.send(embeds=[embed, embed])
File "/home/dave/.pyenv/versions/harambot/lib/python3.10/site-packages/discord/webhook/async.py", line 1843, in send
data = await adapter.execute_webhook(
File "/home/dave/.pyenv/versions/harambot/lib/python3.10/site-packages/discord/webhook/async*.py", line 223, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields: Must be 25 or fewer in length.
In embeds.1.fields: Must be 25 or fewer in length.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/dave/.pyenv/versions/harambot/lib/python3.10/site-packages/discord/app_commands/tree.py", line 1310, in _call
await command._invoke_with_namespace(interaction, namespace)
File "/home/dave/.pyenv/versions/harambot/lib/python3.10/site-packages/discord/app_commands/commands.py", line 883, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "/home/dave/.pyenv/versions/harambot/lib/python3.10/site-packages/discord/app_commands/commands.py", line 876, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'stats' raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.fields: Must be 25 or fewer in length.
In embeds.1.fields: Must be 25 or fewer in length.