diff --git a/sopel_SpiceBot_Runtime_Commands/__init__.py b/sopel_SpiceBot_Runtime_Commands/__init__.py index 7ee0f37..fb28c7f 100644 --- a/sopel_SpiceBot_Runtime_Commands/__init__.py +++ b/sopel_SpiceBot_Runtime_Commands/__init__.py @@ -1,6 +1,14 @@ -import os -for module in os.listdir(os.path.dirname(__file__)): - if module == '__init__.py' or module[-3:] != '.py': - continue - __import__(".%s" % module[:-3], locals(), globals()) -del module +__all__ = [] + +import pkgutil +import inspect + +for loader, name, is_pkg in pkgutil.walk_packages(__path__): + module = loader.find_module(name).load_module(name) + + for name, value in inspect.getmembers(module): + if name.startswith('__'): + continue + + globals()[name] = value + __all__.append(name)