繁体   English   中英

如何回复 discord python 中的引用?

[英]How to reply to a reference in discord python?

我正在尝试制作 discord 机器人,我希望机器人回复我回复的消息。在这张图片中,我希望机器人回复 sahil goyal 的 hi 消息,而不是回复 x1nc。 我该怎么做? 在这张图片中,我希望机器人回复 sahil goyal 的 hi 消息,而不是回复 x1nc。我该怎么做?

on_message事件上,您可以捕获引用的消息。

TARGET_USER = 000000000000000000

@bot.event
async def on_message(message):
    if message.author.id == TARGET_USER and message.reference:
        # assuming you have message cache enabled
        msg_ref = message.reference.cached_message
        await msg_ref.reply("Hello")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM