AttributeError: module 'discord.ext.commands.bot' has no attribute 'command'

AttributeError: module 'discord.ext.commands.bot' has no attribute 'command'

我是 python 的新手,我昨晚制作了一个不和谐的机器人,我做了 cog,这正在发生 请帮助我

import discord
from discord.ext import commands

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

    @commands.command()
    async def hello (self, ctx):
        await ctx.reply('My name is Arson and i dont like anything not even you wth who taught me this')

    @commands.command()
    @commands.has_permissions(ban_members=True)
    async def clear(self, ctx,amount=5):   
        await ctx.channel.purge(limit=amount)


def setup(client):
    client.add_cog(moderation(client))

这个错误来了

Traceback (most recent call last):
  File "C:\Users\burst\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\burst\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke        
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\burst\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped        
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ExtensionFailed: Extension 'cogs.moderation' raised an error: 
AttributeError: module 'discord.ext.commands.bot' has no attribute 'command'

在代码的开头,您应该有一行具有以下结构:

BotName = commands.Bot(description="Discord Bot", command_prefix="!")

然后,不要使用 @commands.command(),而是使用 @BotName.command()