fisher60 / friendo-bot

A Discord Bot that is just a good Friendo
MIT License
25 stars 23 forks source link

Gdwr/update/aoc 2022 #259

Closed GDWR closed 1 year ago

GDWR commented 1 year ago

Update AoC cog to be slashcommands.

- Remove tree.sync on setup
- .aoc leaderboard
- .aoc join
+ Add tree.sync on connection to gateway
+ Ability to load cogs in module format
+ Slashcommand error are logged as expected
+ /advent-of-code join
+ /advent-of-code leaderboard

The leaderboard slashcommand accepts the year and the amount of members to display.

fisher60 commented 1 year ago

I get an error while attempting to run this locally in docker and invoke the advent of code leaderboard command with the existing friendo leaderboard, is there any added configuration I am missing that this feature adds? (This error is spawned with what appears to be a complete and valid JSON response of advent of code data)

friendo_bot-bot-1  |   File "/app/bot/cogs/advent_of_code/_cog.py", line 84, in leaderboard
friendo_bot-bot-1  |     leaderboard = await self.fetch_leaderboard(year)
friendo_bot-bot-1  |   File "/app/bot/cogs/advent_of_code/_cog.py", line 35, in fetch_leaderboard
friendo_bot-bot-1  |     return Leaderboard(**data)
friendo_bot-bot-1  |   File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
friendo_bot-bot-1  | pydantic.error_wrappers.ValidationError: 1 validation error for Leaderboard
friendo_bot-bot-1  | members -> 1818520 -> name
friendo_bot-bot-1  |   none is not an allowed value (type=type_error.none.not_allowed)
friendo_bot-bot-1  |
friendo_bot-bot-1  | The above exception was the direct cause of the following exception:
friendo_bot-bot-1  |
friendo_bot-bot-1  | Traceback (most recent call last):
friendo_bot-bot-1  |   File "/usr/local/lib/python3.9/site-packages/discord/app_commands/tree.py", line 1242, in _call
friendo_bot-bot-1  |     await command._invoke_with_namespace(interaction, namespace)
friendo_bot-bot-1  |   File "/usr/local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 887, in _invoke_with_namespace
friendo_bot-bot-1  |     return await self._do_call(interaction, transformed_values)
friendo_bot-bot-1  |   File "/usr/local/lib/python3.9/site-packages/discord/app_commands/commands.py", line 880, in _do_call
friendo_bot-bot-1  |     raise CommandInvokeError(self, e) from e
friendo_bot-bot-1  | discord.app_commands.errors.CommandInvokeError: Command 'leaderboard' raised an exception: ValidationError: 1 validation error for Leaderboard
friendo_bot-bot-1  | members -> 1818520 -> name
friendo_bot-bot-1  |   none is not an allowed value (type=type_error.none.not_allowed)