def can_run(self, cmd) -> Tuple[bool, list]:
"""
Checks if a command can be ran.
:return: If it can be ran, and a list of conditions that failed.
"""
conditions = getattr(cmd, "cmd_conditions", [])
failed = []
for condition in conditions:
try:
success = condition(self)
if inspect.isawaitable(success):
success = await success
except CommandsError:
raise
except Exception:
failed.append(condition)
else:
if not success:
failed.append(success)
if failed:
return False, failed
return True, []
评论列表
文章目录