japandotorg / Seina-Cogs

My public cogs for red.
https://seina-cogs.readthedocs.io/en/latest/
Other
13 stars 15 forks source link

[BattleRoyale] Error in `br auto` - asset not found. #54

Closed cool-aid-man closed 1 month ago

cool-aid-man commented 1 month ago
Traceback (most recent call last):
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{HOME}/.local/share/Red-DiscordBot/data/pp/cogs/CogManager/cogs/battleroyale/core.py", line 443, in auto
    await game.start(ctx, players=players, original_message=message)
  File "{HOME}/.local/share/Red-DiscordBot/data/pp/cogs/CogManager/cogs/battleroyale/game.py", line 136, in start
    image: discord.File = await self.cog.generate_image(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{HOME}/.local/share/Red-DiscordBot/data/pp/cogs/CogManager/cogs/battleroyale/core.py", line 159, in generate_image
    avatar_1 = Image.open(BytesIO(await user_1.display_avatar.read()))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/asset.py", line 87, in read
    return await self._state.http.get_from_cdn(self.url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/http.py", line 769, in get_from_cdn
    raise NotFound(resp, 'asset not found')
discord.errors.NotFound: 404 Not Found (error code: 0): asset not found

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

Traceback (most recent call last):
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "{HOME}/redenv/lib/python3.11/site-packages/redbot/core/commands/commands.py", line 825, in invoke
    await super().invoke(ctx)
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1650, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1029, in invoke

    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "{HOME}/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 244, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 0): asset not found
japandotorg commented 1 month ago

I'm not entirely sure what might be the reason for this error, since Member/User.display_avatar should always return an discord.Asset (either custom avatar or default discord avatar) The only reason that I can think of this happening is when the user has deleted their account after joining and in middle of a running game.

japandotorg commented 1 month ago

Sorry can't reproduce, if it happens again, make sure to re-open the issue.