2
0
mirror of https://github.com/Nick80835/microbot synced 2025-09-02 07:25:38 +00:00

add locking of commands

This commit is contained in:
Nick80835
2020-06-16 15:16:44 -04:00
parent b91cce15ba
commit 82312d7646
2 changed files with 14 additions and 2 deletions

View File

@@ -53,8 +53,18 @@ class CommandHandler():
event.extras = value["extras"]
try:
await value["function"](event)
if value["locking"]:
if value["locked"]:
await event.reply(f"That command is currently locked, try again later!")
continue
else:
value["locked"] = True
await value["function"](event)
value["locked"] = False
else:
await value["function"](event)
except Exception as exception:
value["locked"] = False
self.logger.warn(f"{value['function'].__name__} - {exception}")
await event.reply(f"`An error occurred in {value['function'].__name__}: {exception}`")
raise exception