2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-30 22:16:05 +00:00

add lockreason

This commit is contained in:
Nick80835
2020-06-16 15:26:52 -04:00
parent 82312d7646
commit 7370d50f91
2 changed files with 6 additions and 6 deletions

View File

@@ -54,17 +54,17 @@ class CommandHandler():
try:
if value["locking"]:
if value["locked"]:
await event.reply(f"That command is currently locked, try again later!")
if value["lockreason"]:
await event.reply(f"That command is currently locked: {value['lockreason']}")
continue
else:
value["locked"] = True
value["lockreason"] = f"In use by **{event.from_id}** (`{event.text}`)"
await value["function"](event)
value["locked"] = False
value["lockreason"] = None
else:
await value["function"](event)
except Exception as exception:
value["locked"] = False
value["lockreason"] = None
self.logger.warn(f"{value['function'].__name__} - {exception}")
await event.reply(f"`An error occurred in {value['function'].__name__}: {exception}`")
raise exception

View File

@@ -69,7 +69,7 @@ class Loader():
"admin": args.get('admin', False),
"owner": args.get('owner', False),
"locking": args.get('locking', False),
"locked": False
"lockreason": None
}
return func