scanner exception handling

This commit is contained in:
Klemek
2021-04-21 20:22:36 +02:00
parent 634f34fb54
commit 6afb05148d
2 changed files with 178 additions and 164 deletions
+1
View File
@@ -115,6 +115,7 @@ python3 src/main.py
* **v1.14**
* `mobile/mention` arg to fix mobile bug
* `%repeat`, `%mobile` to repeat commands
* bug fix
* **v1.13**
* improved scan `%words`
* remove old and unused logs at start and guild leaving
+15 -2
View File
@@ -57,6 +57,8 @@ class Scanner(ABC):
):
args = list(args)
guild = message.guild
progress = None
try:
with GuildLogs(guild) as logs:
# If "%cmd help" redirect to "%help cmd"
if "help" in args:
@@ -168,7 +170,8 @@ class Scanner(ABC):
logs.channels[channel.id].start_date
for channel in self.channels
if channel.id in logs.channels
and logs.channels[channel.id].start_date is not None
and logs.channels[channel.id].start_date
is not None
]
),
)
@@ -221,7 +224,9 @@ class Scanner(ABC):
self.stop_date,
)
)
logging.info(f"scan {guild.id} > results in {delta(t0):,}ms")
logging.info(
f"scan {guild.id} > results in {delta(t0):,}ms"
)
response = ""
first = True
allowed_mentions = (
@@ -249,6 +254,14 @@ class Scanner(ABC):
command_cache.cache(self, message, args)
# Delete custom progress message
await progress.delete()
except Exception as error:
logging.exception(error)
await message.channel.send(
"An unexpected error happened while computing your command, we're sorry for the inconvenience.",
reference=message,
)
if progress is not None:
await progress.delete()
@abstractmethod
async def init(self, message: discord.Message, *args: str) -> bool: