Catch all generic errors
This commit is contained in:
parent
373e95b9af
commit
a9067bbdeb
1 changed files with 13 additions and 4 deletions
|
@ -13,7 +13,7 @@ from dis_snek.api.events.discord import (
|
||||||
MessageDelete,
|
MessageDelete,
|
||||||
MessageUpdate,
|
MessageUpdate,
|
||||||
)
|
)
|
||||||
from dis_snek.client.errors import CommandCheckFailure, CommandOnCooldown
|
from dis_snek.client.errors import CommandCheckFailure, CommandOnCooldown, HTTPException
|
||||||
from dis_snek.client.utils.misc_utils import find_all
|
from dis_snek.client.utils.misc_utils import find_all
|
||||||
from dis_snek.models.discord.channel import DMChannel
|
from dis_snek.models.discord.channel import DMChannel
|
||||||
from dis_snek.models.discord.embed import EmbedField
|
from dis_snek.models.discord.embed import EmbedField
|
||||||
|
@ -107,7 +107,7 @@ class Jarvis(Snake):
|
||||||
|
|
||||||
@listen()
|
@listen()
|
||||||
async def on_ready(self) -> None:
|
async def on_ready(self) -> None:
|
||||||
"""Lepton on_ready override."""
|
"""NAFF on_ready override."""
|
||||||
await self._sync_domains()
|
await self._sync_domains()
|
||||||
self._update_domains.start()
|
self._update_domains.start()
|
||||||
self.logger.info("Logged in as {}".format(self.user)) # noqa: T001
|
self.logger.info("Logged in as {}".format(self.user)) # noqa: T001
|
||||||
|
@ -118,10 +118,19 @@ class Jarvis(Snake):
|
||||||
"{}&permissions=8&scope=bot%20applications.commands".format(self.user.id)
|
"{}&permissions=8&scope=bot%20applications.commands".format(self.user.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def on_error(self, source: str, error: Exception, *args, **kwargs) -> None:
|
||||||
|
"""NAFF on_error override."""
|
||||||
|
if isinstance(error, HTTPException):
|
||||||
|
errors = error.search_for_message(error.errors)
|
||||||
|
out = f"HTTPException: {error.status}|{error.response.reason}: " + "\n".join(errors)
|
||||||
|
self.logger.error(out, exc_info=error)
|
||||||
|
else:
|
||||||
|
self.logger.error(f"Ignoring exception in {source}", exc_info=error)
|
||||||
|
|
||||||
async def on_command_error(
|
async def on_command_error(
|
||||||
self, ctx: Context, error: Exception, *args: list, **kwargs: dict
|
self, ctx: Context, error: Exception, *args: list, **kwargs: dict
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Lepton on_command_error override."""
|
"""NAFF on_command_error override."""
|
||||||
self.logger.debug(f"Handling error in {ctx.invoked_name}: {error}")
|
self.logger.debug(f"Handling error in {ctx.invoked_name}: {error}")
|
||||||
if isinstance(error, CommandOnCooldown):
|
if isinstance(error, CommandOnCooldown):
|
||||||
await ctx.send(str(error), ephemeral=True)
|
await ctx.send(str(error), ephemeral=True)
|
||||||
|
@ -186,7 +195,7 @@ class Jarvis(Snake):
|
||||||
|
|
||||||
# Modlog
|
# Modlog
|
||||||
async def on_command(self, ctx: Context) -> None:
|
async def on_command(self, ctx: Context) -> None:
|
||||||
"""Lepton on_command override."""
|
"""NAFF on_command override."""
|
||||||
if not isinstance(ctx.channel, DMChannel) and ctx.invoked_name not in ["pw"]:
|
if not isinstance(ctx.channel, DMChannel) and ctx.invoked_name not in ["pw"]:
|
||||||
modlog = await Setting.find_one(q(guild=ctx.guild.id, setting="activitylog"))
|
modlog = await Setting.find_one(q(guild=ctx.guild.id, setting="activitylog"))
|
||||||
if modlog:
|
if modlog:
|
||||||
|
|
Loading…
Add table
Reference in a new issue