Add error handling in client

This commit is contained in:
Zeva Rose 2022-04-30 19:28:20 -06:00
parent 7af0b765f8
commit 966738b524
3 changed files with 12 additions and 5 deletions

View file

@ -179,7 +179,10 @@ class Jarvis(Snake):
f"\nException:\n```py\n{error_message}\n```"
)
await ctx.send("Whoops! Encountered an error. The error has been logged.", ephemeral=True)
return await super().on_command_error(ctx, error, *args, **kwargs)
try:
return await super().on_command_error(ctx, error, *args, **kwargs)
except Exception as e:
self.logger.error("Uncaught exception", exc_info=e)
# Modlog
async def on_command(self, ctx: Context) -> None:
@ -368,8 +371,11 @@ class Jarvis(Snake):
async def roleping(self, message: Message) -> None:
"""Handle roleping events."""
if message.author.has_permission(Permissions.MANAGE_GUILD):
return
try:
if message.author.has_permission(Permissions.MANAGE_GUILD):
return
except Exception as e:
self.logger.error("Failed to get permissions, pretending check failed", exc_info=e)
if await Roleping.collection.count_documents(q(guild=message.guild.id, active=True)) == 0:
return
rolepings = await Roleping.find(q(guild=message.guild.id, active=True)).to_list(None)

4
poetry.lock generated
View file

@ -281,7 +281,7 @@ python-versions = ">=3.5"
[[package]]
name = "jarvis-core"
version = "0.8.2"
version = "0.8.4"
description = "JARVIS core"
category = "main"
optional = false
@ -300,7 +300,7 @@ umongo = "^3.1.0"
type = "git"
url = "https://git.zevaryx.com/stark-industries/jarvis/jarvis-core.git"
reference = "main"
resolved_reference = "0184d89d38660cd063c779b35f3e9ccc4ba86598"
resolved_reference = "94b1ecb478bdd61989cba850364d1242f6759982"
[[package]]
name = "marshmallow"

View file

@ -25,6 +25,7 @@ aiofile = "^3.7.4"
molter = "^0.11.0"
asyncpraw = "^7.5.0"
rook = "^0.1.170"
rich = "^12.3.0"
[build-system]
requires = ["poetry-core>=1.0.0"]