first commit

This commit is contained in:
2026-04-29 17:41:10 -05:00
parent f53104d947
commit 0fe6bd7ea6
15 changed files with 1678 additions and 33 deletions

26
bot/commands/__init__.py Normal file
View File

@@ -0,0 +1,26 @@
import os
import importlib.util
import logging
logger = logging.getLogger(__name__)
def load_commands():
"""
Automatically discover and load command modules from bot/commands/.
Each module should call register_module() during import.
"""
commands_dir = os.path.dirname(__file__)
for filename in os.listdir(commands_dir):
if filename.endswith('.py') and filename != '__init__.py':
module_name = filename[:-3] # remove .py
module_path = os.path.join(commands_dir, filename)
try:
spec = importlib.util.spec_from_file_location(module_name, module_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
logger.info(f"Loaded command module: {module_name}")
except Exception as e:
logger.error(f"Failed to load command module {module_name}: {e}")