AttributeError:'Client'对象没有属性'command'

问题描述 投票:0回答:1

我已经添加了这段代码:@client.command(pass_context=True) async def name(ctx): username = ctx.message.author.display_name到我的代码行的末尾,当我试图让机器人在线时,我得到了上面的错误。

python-3.x error-handling discord.py
1个回答
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")
© www.soinside.com 2019 - 2024. All rights reserved.