Python 属性错误模块';不和谐';没有属性';命令';

Python 属性错误模块';不和谐';没有属性';命令';,python,discord.py,Python,Discord.py,因此,我遵循Python Discord教程创建Discord机器人,当我测试它时说“AttributeError类型对象'Client'没有属性'command'”,我找不到任何答案。 (我也尝试过使用client=discord.client()) 这是我的密码: import discord from discord import client from discord.ext import commands class MyClient(discord.Client):

因此,我遵循Python Discord教程创建Discord机器人,当我测试它时说“AttributeError类型对象'Client'没有属性'command'”,我找不到任何答案。 (我也尝试过使用
client=discord.client()
) 这是我的密码:

import discord
from discord import client
from discord.ext import commands
 


class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return
        
        if message.content == ("/id"): 
            await message.channel.send(message.channel.id)

        if message.content == (".read"):
            with open("database.txt", "r") as f:
                content = f.read()
            await message.channel.send(content)

    @commands.has_permissions(administrator=True)
    @discord.command() 
    async def admins_only_command(ctx, *, args):
            if message.content == ("/apply"):
             with open("database.txt", "a") as f:
                f.write(f"\n" + str(message.channel.id))
            await message.channel.send("Data stored successfully: " + str(message.channel.id))


       
        
      
            
client = MyClient()
client.run(TOKEN) 


我不是专家,但快速阅读一下就会发现,出现此错误的原因是因为您试图访问一个实际上不存在的属性

您试图得到的是“discord.command()”。您需要的是“discord.ext.commands.command()”

改变

@discord.command()


它没有给出任何错误rn,但我的代码这次不起作用。我假设这是因为async def admins_only_命令(ctx,*,args):没有定义“message”,所以“message.content”不存在@哦,非常感谢你,很高兴能帮忙。希望你让你的机器人工作。这次它没有给出任何错误,但不工作。它在没有该部分的情况下工作,btw
@commands.has_权限(administrator=True)@commands.command()异步def admins_only_命令(ctx,*,args):
@commands.command()