gpt4 book ai didi

javascript - 不和谐.js v12 : How do I await for messages in a DM channel?

转载 作者:行者123 更新时间:2023-12-03 12:19:21 34 4
gpt4 key购买 nike

这是我尝试过的代码:

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

const filter = (m) => m.author.id === message.author.id
message.author.dmChannel.awaitMessages(filter)
.then((collected) => console.log(collected.first().content))

关于javascript - 不和谐.js v12 : How do I await for messages in a DM channel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62616893/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com