这是我尝试过的代码:
message.author.dmChannel.awaitMessages(msg => {
console.log(msg.content)
});
但它返回此错误消息:
TypeError: Cannot read property 'awaitMessages' of null
更新代码:
message.author.send("What is your name?")
const filter = m => m.author.id === message.author.id
message.author.dmChannel.awaitMessages(filter)
.then((collected) => console.log(collected.first().content))
你没有正确使用awaitMessages()
,你需要传递一个filter
You're not using awaitMessages()
properly, you need to pass a filter
const filter = (m) => m.author.id === message.author.id
message.author.dmChannel.awaitMessages(filter)
.then((collected) => console.log(collected.first().content))
这篇关于discord.js v12:我如何等待 DM 频道中的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!