From e5491df60dff5d91eb63a2ac08665168c3130fcd Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Thu, 9 Mar 2023 04:26:21 +0000 Subject: [PATCH] Add exception type display in embed on failing of any cog command --- main.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index cb04f10e..ededa43f 100644 --- a/main.py +++ b/main.py @@ -276,7 +276,14 @@ async def load(ctx: ApplicationContext, cog: str): try: client.load_extension(f"cogs.{cog}") await ctx.respond(embed=discord.Embed(description=f"{cog} cog successfully loaded.", color=discord.Color.green())) - except Exception as e: await ctx.respond(embed=discord.Embed(description=f"{cog} failed to load: {e}", color=discord.Color.red())) + except Exception as e: + await ctx.respond( + embed=discord.Embed( + title=f"{cog} failed to load", + description=f"```{type(e).__name__}: {e}```", + color=discord.Color.red() + ) + ) @cogs.command( name="disable", @@ -288,7 +295,14 @@ async def disable(ctx: ApplicationContext, cog: str): try: client.unload_extension(f"cogs.{cog}") await ctx.respond(embed=discord.Embed(description=f"{cog} cog successfully disabled.", color=discord.Color.green())) - except: await ctx.respond(embed=discord.Embed(description=f"{cog} cog not found."), color=discord.Color.red()) + except Exception as e: + await ctx.respond( + embed=discord.Embed( + title=f"{cog} failed to disable", + description=f"```{type(e).__name__}: {e}```", + color=discord.Color.red() + ) + ) @cogs.command( name="reload", @@ -300,7 +314,14 @@ async def reload(ctx: ApplicationContext, cog: str): try: client.reload_extension(f"cogs.{cog}") await ctx.respond(embed=discord.Embed(description=f"{cog} cog successfully reloaded.", color=discord.Color.green())) - except: await ctx.respond(embed=discord.Embed(description=f"{cog} cog not found.", color=discord.Color.red())) + except Exception as e: + await ctx.respond( + embed=discord.Embed( + title=f"{cog} failed to reload", + description=f"```{type(e).__name__}: {e}```", + color=discord.Color.red() + ) + ) # Initialization active_cogs = [