Python Discord bot扩展运行良好,但不';行不通

Python Discord bot扩展运行良好,但不';行不通,python,discord,discord.py,bots,Python,Discord,Discord.py,Bots,我可以很好地加载扩展,但是每当我在Discord上尝试Qball/.Qball/Qball时,bot都不会响应 Quokkabot.py(主) Quokkabot2.py(cog) cog上的命令应定义为该cog上的实例方法 class Commands(commands.Cog): def __init__(self, client): self.client = client @commands.command(aliases=['Qball, test']

我可以很好地加载扩展,但是每当我在Discord上尝试Qball/.Qball/Qball时,bot都不会响应

Quokkabot.py(主)

Quokkabot2.py(cog)


cog上的命令应定义为该cog上的实例方法

class Commands(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.command(aliases=['Qball, test'])
    async def _Qball(self, ctx):
        responses = [#answers]
        await ctx.send(f'{random.choice(responses)}')
那么,在你的主要

client = commands.Bot(command_prefix = '.')
client.add_cog(Commands(client))

你好@Silvio Mayolo,非常感谢您的回答。我按照你说的做了,现在我得到了这个错误:
client.add_cog(Commands(client))name错误:没有定义name“Commands”
Commands
是你在代码段中为类命名的。您可能键入了错误的类名吗?我在命令之前添加了
def main():
,我不再收到错误,但bot仍然没有不一致的响应。
class Commands(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.command(aliases=['Qball, test'])
    async def _Qball(self, ctx):
        responses = [#answers]
        await ctx.send(f'{random.choice(responses)}')
client = commands.Bot(command_prefix = '.')
client.add_cog(Commands(client))