浏览代码

Fixing problems on the cogs import

BaumSplitter41 4 月之前
父节点
当前提交
234a693869
共有 1 个文件被更改,包括 6 次插入2 次删除
  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}")