我尝试使用函数时 discord.py 出错

时间:2021-02-06 00:59:00

标签: python syntax-error discord.py

当我尝试运行我的机器人时,我收到一个错误:attributeError: 'Client' object has no attribute 'command' 它源自的代码是 @client.command() async def beg(ctx):

1 个答案:

答案 0 :(得分:3)

documentation 建议:

from discord.ext import commands

bot = commands.Bot(command_prefix='$')

@bot.command()
async def test(ctx):
    pass

# or:

@commands.command()
async def test(ctx):
    pass

bot.add_command(test)

如果您想得到考虑到您的具体问题的答案,请发布minimal reproducible example

相关问题