如何让机器人在触发词之后保存消息(discord.py)

时间:2020-11-06 23:04:04

标签: discord bots discord.py

我正试图让我的机器人响应在触发词之后发送的消息,但它所做的只是向我发送以下错误:AttributeError: 'generator' object has no attribute 'content'。这是我的代码:

@client.event
async def on_message(message):
    if message.content == "report":
        await message.author.send("Type your report below")
        def check(m):
            return m.guild == None and m.author == message.author
        try:
            response = client.wait_for("message", check=check)
        except asyncio.TimeoutError:
            await message.author.send("Uh-oh, the request timed out! Try again.")
        else:
            content = response.content

谢谢!

1 个答案:

答案 0 :(得分:0)

client.wait_for是协程函数。这意味着,要使用它,您必须等待它。

您只需要做:

response = await client.wait_for("message", check=check)