【问题标题】:Get the message object of a message you replied to (Discord.py)获取您回复的消息的消息对象 (Discord.py)
【发布时间】:2021-07-12 14:48:47
【问题描述】:

如何获取我回复的消息的消息对象?例如。有人说“你好,你好吗!”。我回复了那条调用.good 命令的消息,它会打印消息(你好,你好吗!)的消息对象。我查看了所有 discord.py 文档,但没有看到提到这样的事情。

【问题讨论】:

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


    【解决方案1】:

    您可以使用discord.Message.reference 属性。在你的问题中,你会做这样的事情:

    @client.command()
    async def good(ctx):
        # If this message has a reference (meaning it's a reply)
        if ctx.message.reference:
            original = await ctx.fetch_message(id=ctx.message.reference.message_id)
            text = original.content
            print(f"Author said {text}")
    
    

    这是文档的链接:https://discordpy.readthedocs.io/en/stable/api.html#discord.Message.reference

    【讨论】:

      猜你喜欢
      • 2020-07-27
      • 1970-01-01
      • 1970-01-01
      • 2021-03-25
      • 1970-01-01
      • 2019-01-12
      • 2019-04-21
      • 1970-01-01
      • 2021-07-01
      相关资源
      最近更新 更多