AttributeError:“客户端”对象没有属性“命令”

时间:2019-04-20 22:39:01

标签: python-3.x error-handling discord.py

我已经在代码行的末尾添加了以下代码:@client.command(pass_context=True) async def name(ctx): username = ctx.message.author.display_name,在尝试使机器人在线时,出现了以上错误。

1 个答案:

答案 0 :(得分:0)

您需要使用discord.ext.commands.Bot而不是discord.ClientBotClient的子类,因此您还可以将所有Client功能与Bot实例一起使用

from discord.ext.commands import Bot

bot = Bot("!")

@bot.command()
async def test(ctx):
    await ctx.send("Command executed")

await bot.run("TOKEN")
相关问题