浏览代码

printing cog list in start up in discord

BaumSplitter41 2 月之前
父节点
当前提交
20905afd5b
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      VPD_BOT/main.py

+ 5 - 2
VPD_BOT/main.py

@@ -144,17 +144,20 @@ bot = commands.Bot(
 )
 
 #Loading Cogs
-def load_extensions():
+async def load_extensions():
     cogs_dir = "./cogs"
     if not os.path.exists(cogs_dir):
         print(f"Cogs directory '{cogs_dir}' not found!")
         return
+    channel = discord.utils.get(bot.guilds[0].channels, id=int(channel_status_log))
     for filename in os.listdir(cogs_dir):
         if filename.endswith(".py"):
             cog_list = os.path.splitext(filename)[0]
             try:
                 bot.load_extension(f"cogs.{cog_list}")
                 print(f"Loaded cog: {cog_list}")
+                if channel and cog_list:
+                    await channel.send(f"Registered Slash-Commands:\n{cog_list}")
             except Exception as e:
                 print(f"Failed to load cog {cog_list}: {e}")
 
@@ -647,6 +650,6 @@ async def update_users_periodically():
 
 #---------------------------------#
 #Run function
-load_extensions()
+bot.loop.create_task(load_extensions())
 bot.run(token)
 #---------------------------------#