flaree / lastfm-red

LastFM Ported to Red
MIT License
3 stars 3 forks source link

Some errors in last.fm #19

Closed ltzmax closed 1 year ago

ltzmax commented 1 year ago

i've gotten 3 errors from the cog on dpy2.

This is from fm server nowplaying

Traceback (most recent call last):
  File "/home/max/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/max/redbot/cogs/CogManager/cogs/lastfm/nowplaying.py", line 151, in command_servernp
    icon_url=ctx.guild.icon_url_as(size=64),
             ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Guild' object has no attribute 'icon_url_as'

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

Traceback (most recent call last):
  File "/home/max/redenv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "/home/max/redenv/lib/python3.11/site-packages/redbot/core/commands/commands.py", line 791, in invoke
    await super().invoke(ctx)
  File "/home/max/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1650, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/max/redenv/lib/python3.11/site-packages/redbot/core/commands/commands.py", line 791, in invoke
    await super().invoke(ctx)
  File "/home/max/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1650, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/max/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/max/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: AttributeError: 'Guild' object has no attribute 'icon_url_as'

This is from fm nowplaying, it only shows in logs when a user hasn't logged in yet.

Traceback (most recent call last):
  File "/home/max/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/max/redbot/cogs/CogManager/cogs/lastfm/nowplaying.py", line 25, in command_nowplaying
    self.check_if_logged_in(conf, user == ctx.author)
  File "/home/max/redbot/cogs/CogManager/cogs/lastfm/utils/base.py", line 265, in check_if_logged_in
    raise NotLoggedInError(
lastfm.exceptions.NotLoggedInError: They need to log into a last.fm account. Please log in with `fm login`.

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

Traceback (most recent call last):
  File "/home/max/redenv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "/home/max/redenv/lib/python3.11/site-packages/redbot/core/commands/commands.py", line 791, in invoke
    await super().invoke(ctx)
  File "/home/max/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 1650, in invoke
    await ctx.invoked_subcommand.invoke(ctx)
  File "/home/max/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/max/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: NotLoggedInError: They need to log into a last.fm account. Please log in with `fm login`.

This is from whoknows

Traceback (most recent call last):
  File "/home/max/redenv/lib/python3.11/site-packages/discord/ext/commands/core.py", line 235, in wrapped
    ret = await coro(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/max/redbot/cogs/CogManager/cogs/lastfm/whoknows.py", line 30, in command_whoknows
    trackname, artistname, albumname, image_url = await self.get_current_track(
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/max/redbot/cogs/CogManager/cogs/lastfm/utils/api.py", line 83, in get_current_track
    raise NotScrobblingError("You aren't currently listening to anything.")
lastfm.exceptions.NotScrobblingError: You aren't currently listening to anything.

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

Traceback (most recent call last):
  File "/home/max/redenv/lib/python3.11/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
    await ctx.command.invoke(ctx)
  File "/home/max/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/max/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: NotScrobblingError: You aren't currently listening to anything.
Ryan5453 commented 1 year ago

I've pushed a fix for the first error in v1.7.1, thanks for catching that. The others are just your error handler (iirc the errorlogs cog is famous for this) incorrectly handling the exception, as the cog sends a message to the user and Red's main exception handler is never reached.