[英]How can I check if a message is a reply and check the replied message content? (discord.js)
這是我的目標:檢查包含命令的消息是否是對其他消息的回復如果是,則檢查用戶回復的消息的內容。 例如: 消息 1:您好? 你好嗎:消息 2(對消息 1 的回復):!command
現在我希望我的機器人檢查消息 2 是否是回復,如果是,請檢查消息 1 的 console.log 內容
我正在使用 discord.js v13。
您可以使用<Message>.reference
來檢查回復。
例如,要檢查msg2
是否是對msg1
的回復並記錄msg1
的內容:
if (msg2.type === 'REPLY' && msg2.reference.messageId === msg1.id)
console.log(msg1.content);
如果您沒有msg1
並且需要查找它,則可以使用<Message>.fetchReference
來獲取回復。
if (msg2.type === 'REPLY') {
const msg1 = await msg2.fetchReference();
console.log(msg1.content);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.