我是 Discord 机器人制作的新手,但是我对 on_message 等命令相当熟悉,并且目前正在运行一个简单的机器人,可以在被询问时从列表中提供电影推荐。
如果机器人得到回复,是否有任何方法可以读取回复内容以及回复的消息内容?我正在尝试对其进行设置,以便如果机器人建议一部电影并且使用特定单词回复该消息,它将从列表中删除该电影。
非常感谢任何帮助,谢谢。
在discord.py上,你可以这样做
referenced_message = original_msg['reference']['resolved']
用于消息对象本身,然后 referenced_message['content']
从对象获取消息内容
您的使用案例的示例代码:
@bot.event
async def on_message(message):
replied_to = True if message['reference']['resolved'] is not None else False
if replied_to:
message_reference = message['reference']['resolved']
original_msg_content = message_reference['content']
#do extra logic about the movie stuff and then send the message away
希望有帮助!