Parcourir la source

Fixing problems on the cogs import

BaumSplitter41 il y a 4 mois
Parent
commit
234a693869
1 fichiers modifiés avec 6 ajouts et 2 suppressions
  1. 6 2
      VPD_BOT/main.py

+ 6 - 2
VPD_BOT/main.py

@@ -128,9 +128,13 @@ bot = commands.Bot(
 )
 
 async def load_extensions():
-    for filename in os.listdir("cogs"):
+    cogs_dir = "cogs"
+    if not os.path.exists(cogs_dir):
+        return
+    for filename in os.listdir(cogs_dir):
         if filename.endswith(".py"):
-            bot.load_extension(f"cogs.{filename[:-3]}")   
+            module_name = os.path.splitext(filename)[0]
+            bot.load_extension(f"cogs.{module_name}")