Skip to content

Commit

Permalink
Added catching for invalid responses
Browse files Browse the repository at this point in the history
  • Loading branch information
justalemon committed Jun 22, 2023
1 parent 91d49c1 commit 5f8df37
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions leek/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import aiomysql
from aiohttp.client import _RequestContextManager
from aiomysql import Pool, Connection
from discord import AutoShardedBot, ApplicationContext, DiscordException, Embed, SlashCommand
from discord import AutoShardedBot, ApplicationContext, DiscordException, Embed, SlashCommand, NotFound

from .localization import localize, get_default, get_localizations

Expand Down Expand Up @@ -147,9 +147,14 @@ async def on_application_command_error(self, ctx: ApplicationContext, exception:
if self.debug:
info = traceback.format_exception(type(exception), exception, exception.__traceback__)
text = "\n".join(info)
await ctx.respond(f"```\n{text}\n```", ephemeral=True)
message = f"```\n{text}\n```"
else:
await ctx.respond(localize("BOT_EXCEPTION_OCURRED", ctx.locale), ephemeral=True)
message = localize("BOT_EXCEPTION_OCURRED", ctx.locale)

try:
await ctx.respond(message, ephemeral=True)
except NotFound:
await ctx.send(message, delete_after=60)

await super().on_application_command_error(ctx, exception)

Expand Down

0 comments on commit 5f8df37

Please sign in to comment.