【问题标题】:How to get a bot to save the message after a trigger word (discord.py)如何让机器人在触发词后保存消息(discord.py)
【发布时间】:2021-02-19 15:55:27
【问题描述】:

我试图让我的机器人响应在触发词之后发送的消息,但它所做的只是向我发送以下错误: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

提前致谢!

【问题讨论】:

    标签: discord bots discord.py


    【解决方案1】:

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

    你只需要这样做:

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

    【讨论】:

      猜你喜欢
      • 2022-01-03
      • 2021-10-14
      • 2020-11-08
      • 1970-01-01
      • 2019-09-19
      • 1970-01-01
      • 2021-01-26
      • 2021-04-11
      • 2022-12-01
      相关资源
      最近更新 更多