From c1df6ba0184318c50c92d8540eea25e0b427f6a2 Mon Sep 17 00:00:00 2001 From: yuki Date: Tue, 7 Oct 2025 06:04:32 -0300 Subject: [PATCH] better error printing --- commands/now_playing.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/commands/now_playing.py b/commands/now_playing.py index 3f87977..43ed7b3 100644 --- a/commands/now_playing.py +++ b/commands/now_playing.py @@ -13,7 +13,7 @@ def setup(bot: bot.Bot): try: username = await bot.get_lastfm(ctx.author.id) except Exception as e: print(e) - await ctx.send(u.error_msg("Unknown database error.")) + await ctx.send(u.error_msg(f"Unknown database error:\n{e}")) if not username: await ctx.send(u.error_msg("Please provide a Last.fm username (or set yours with `/setfm`)")) @@ -41,12 +41,13 @@ def setup(bot: bot.Bot): except IndexError: await ctx.send(u.error_msg(f"User **{username}** has no recent tracks or they're set to private.")) - except pylast.WSError: - await ctx.send(u.error_msg(f"User **{username}** not found.")) + except pylast.WSError as e: + print(e) + await ctx.send(u.error_msg(f"Last.fm error:\n`{e}`")) except Exception as e: print(e) - await ctx.send(u.error_msg("Unknown error.")) + await ctx.send(u.error_msg(f"Unknown error:\n`{e}`")) @bot.command(name="cover", aliases=["coverart","art"]) @bot.slash_command(name="cover", description="Returns cover art of last played album or a custom query.") @@ -77,7 +78,7 @@ def setup(bot: bot.Bot): except Exception as e: print(e) - await ctx.send(u.error_msg("Unknown error.")) + await ctx.send(u.error_msg(f"Unknown error:\n`{e}`")) else: try: if "|" not in album: @@ -96,9 +97,10 @@ def setup(bot: bot.Bot): f"Here's the cover art for **[{albumobj.get_name(properly_capitalized=True)}]({albumobj.get_url()})**:\ {cover_art}" ) + except pylast.WSError as e: print(e) - await ctx.send(u.error_msg(e)) + await ctx.send(u.error_msg(f"Last.fm error:\n`{e}`")) except Exception as e: print(e) - await ctx.send(u.error_msg("Unknown parsing error.")) + await ctx.send(u.error_msg(f"Unknown parsing error:\n`{e}`"))