diff --git a/cogs/image_service_cog.py b/cogs/image_service_cog.py index 958eb045..abb572b9 100644 --- a/cogs/image_service_cog.py +++ b/cogs/image_service_cog.py @@ -86,7 +86,11 @@ async def draw_command( except Exception as e: print(e) traceback.print_exc() - await safe_ctx_respond(ctx=ctx, content="Something went wrong. Please try again later.", ephemeral=from_action) + await safe_ctx_respond( + ctx=ctx, + content="Something went wrong. Please try again later.", + ephemeral=from_action, + ) await ctx.send_followup(e, ephemeral=from_action) async def draw_old_command( @@ -123,7 +127,11 @@ async def draw_old_command( except Exception as e: print(e) traceback.print_exc() - await safe_ctx_respond(ctx=ctx, content="Something went wrong. Please try again later.", ephemeral=from_action) + await safe_ctx_respond( + ctx=ctx, + content="Something went wrong. Please try again later.", + ephemeral=from_action, + ) await ctx.send_followup(e, ephemeral=from_action) @@ -151,7 +159,9 @@ async def local_size_command(self, ctx: discord.ApplicationContext): # Format the size to be in MB and send. total_size = total_size / 1000000 - await safe_ctx_respond(ctx=ctx, content=f"The size of the local images folder is {total_size} MB.") + await safe_ctx_respond( + ctx=ctx, content=f"The size of the local images folder is {total_size} MB." + ) async def clear_local_command(self, ctx): """Delete all local images""" diff --git a/utils/__init__.py b/utils/__init__.py index c1b73613..be5ef424 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -1 +1 @@ -from .safe_ctx_respond import safe_ctx_respond \ No newline at end of file +from .safe_ctx_respond import safe_ctx_respond diff --git a/utils/safe_ctx_respond.py b/utils/safe_ctx_respond.py index 6ce979d0..b75e7f41 100644 --- a/utils/safe_ctx_respond.py +++ b/utils/safe_ctx_respond.py @@ -19,7 +19,7 @@ async def safe_ctx_respond(ctx: discord.ApplicationContext, content: str) -> Non Raises: ValueError: If `ctx` is not provided in the `kwargs`. - + Examples: ```py # Respond to an interaction @@ -33,8 +33,8 @@ async def safe_ctx_respond(ctx: discord.ApplicationContext, content: str) -> Non try: await ctx.message.reply(content) except ( - discord.NotFound, - AttributeError, + discord.NotFound, + AttributeError, ): # AttributeError is raised when ctx.message is None, NotFound is raised when the message is not found # If the message is not found, send a new message to the channel content = f"**{ctx.message.author.mention}** \n{content}".strip(