-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmds.py
25 lines (22 loc) · 1018 Bytes
/
cmds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import importlib
import logging
import os
logger = logging.getLogger('AlphaLLM')
async def setup_commands(bot):
"""
Charge dynamiquement les commandes depuis plusieurs répertoires.
"""
commands_dir = ['commands', 'admin_commands', 'config_commands']
for commands_directory in commands_dir:
for filename in os.listdir(commands_directory):
if filename.endswith('.py') and filename != '__init__.py':
module_name = f'{commands_directory}.{filename[:-3]}'
try:
module = importlib.import_module(module_name)
if hasattr(module, 'setup'):
await module.setup(bot)
logger.info(f"Commande {filename[:-3]} chargée")
else:
logger.warning(f"Le fichier {filename} n'a pas de fonction 'setup'")
except Exception as e:
logger.error(f"Erreur lors du chargement de {filename}: {str(e)}")