如何检测用户是否回复了 discord.js 中的机器人消息? [英] How can you detect if a user replied to a message of a bot in discord.js?

查看:25
本文介绍了如何检测用户是否回复了 discord.js 中的机器人消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经搜索了 discord.js 文档,但我找不到让机器人检测他们自己的消息是否由 discord 服务器中的用户回复的方法.有没有办法做到这一点?

I have searched the discord.js documentation but I can't find a way to make the bot detect if their own messages were replied by a user in a discord server. Is there a way to do this?

非常感谢,保罗10

推荐答案

所有消息都有一个 message_reference 属性.这包含公会、频道和消息 ID.如果不是回复,则此属性为 null.我假设您已经知道该频道.

All messages have a message_reference property. This contains the guild, channel and message id. This property is null if it isn’t a reply. I assume you already know the channel.

//async function
//message is an instance of Message
let { channel, message_reference: reply } = message
const repliedTo = await channel.messages.fetch(reply.message_id);
//repliedTo is now the replied message with author, content, etc

这篇关于如何检测用户是否回复了 discord.js 中的机器人消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆