Skip to content

Commit

Permalink
Add error handling to commands to fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed Apr 19, 2023
1 parent 9744d25 commit 2c0d634
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ def load_commands(self):
module = importlib.import_module(f"commands.{module_name}")
if issubclass(getattr(module, module_name), Commands):
command_class = getattr(module, module_name)()
for command_name, command_function in command_class.commands.items():
params = self.get_command_params(command_function)
commands.append((command_name, command_function.__name__, params))
if hasattr(command_class, 'commands'):
for command_name, command_function in command_class.commands.items():
params = self.get_command_params(command_function)
commands.append((command_name, command_function.__name__, params))
if not commands:
# No commands imported for {module_name} due to missing configuration requirements.
return []
return commands

def get_command_params(self, func):
Expand Down

0 comments on commit 2c0d634

Please sign in to comment.