【发布时间】:2023-01-26 05:17:38
【问题描述】:
我的机器人程序无法检测到 cogs 文件 我已经尝试了各种方法来解决它,但仍然没有任何改变
主程序
import discord
import os
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='$', intents=intents)
async def load():
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
await bot.load_extension(f'cogs.{filename[:-3]}')
bot.run('MTA2NzQ1MDMxMTAzMzIzMzUxOA.GSdg-i.CW3X5T82VYGYjPqEPWZ8YQ6oDZni33T-Bi1Ovo')
实验室.py
import discord
from discord.ext import commands
class lab(commands.Cog):
def __init__(self,bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print('lab.py is running')
@commands.command()
async def holla(ctx):
await ctx.reply('hai')
async def setup(bot):
await bot.add_cog(lab(bot))
我需要有人帮我解决我的问题,在此先感谢
【问题讨论】:
-
不要在互联网上共享您的令牌。请考虑在不和谐的开发者门户中重新生成一个