[英]discord py - Send a different message if a user replies to my bot
I want to send a specific message if anyone replies to a message from my discord bot, I tried many things, but can't find a solution.如果有人回复来自我的 discord 机器人的消息,我想发送特定消息,我尝试了很多东西,但找不到解决方案。 Aside from that, it is new in 1.6 and I can't find it in the docs from discord.
除此之外,它是 1.6 中的新功能,我在 discord 的文档中找不到它。 I found "reference" but don't understand how I can use that.
我找到了“参考”,但不明白如何使用它。
What I tried:我尝试了什么:
if len(message.replies) >= 0:
await ctx.send('thanks for reply dude')
but sadly, that doesn't work.但遗憾的是,这行不通。
It's not message.replies
, it's message.reference
这不是
message.replies
,而是message.reference
if message.reference is not None:
await ctx.send("Thanks for the reply dude")
if message.reference is not None:
if message.reference.cached_message is None:
# Fetching the message
channel = bot.get_channel(message.reference.channel_id)
msg = await channel.fetch_message(message.reference.message_id)
else:
msg = message.reference.cached_message
Note that this still has some flaws, the message_id
attribute can also be None
注意这个还是有一些缺陷的,
message_id
属性也可以是None
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.