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

Python 属性错误模块';不和谐。客户';没有属性';命令';,python,discord.py,Python,Discord.py,因此,我遵循了一个关于创建Discord机器人的Python Discord教程。当我运行代码时,它说“AttributeError模块'discord.client'没有'command'属性”。我尝试使用commands.command()它没有给出任何错误,但这次它不起作用。这是我的密码: from discord import message from discord import client from discord.ext import commands class MyCl

因此,我遵循了一个关于创建Discord机器人的Python Discord教程。当我运行代码时,它说“AttributeError模块'discord.client'没有'command'属性”。我尝试使用commands.command()它没有给出任何错误,但这次它不起作用。这是我的密码:

from discord import message
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)
   
    @client.command()
    @commands.has_permissions(ban_members=True)
    async def admin_only_commands(self, message):
        if message.author == self.user:
            return
        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.ext中的commands.bot

来自discord.ext导入命令
从discord导入消息
bot=commands.bot(命令前缀=“!”,不区分大小写=True)
@机器人事件
异步def on_就绪(自):
打印('登录身份',self.user)
@机器人事件
_消息上的异步定义(self,message):
#不要回应我们自己
如果message.author==self.user:
返回
如果message.content==(“/id”):
等待message.channel.send(message.channel.id)
如果message.content==(“.read”):
以open(“database.txt”、“r”)作为f:
content=f.read()
等待消息。频道。发送(内容)
@bot.command()
@commands.has_权限(ban_members=True)
异步def admin_only_命令(self、message):
如果message.author==self.user:
返回
如果message.content==(“/apply”):
以open(“database.txt”、“a”)作为f:
f、 写入(f“\n”+str(message.channel.id))
等待message.channel.send(“成功存储的数据:+str(message.channel.id))
bot.run(令牌)

现在更新@Blo