我想在DMs中有一条等待消息!
但是它是如何工作的呢?
message.channel.awaitMessages( {max: 1, time: 10000})
.then(async(collected) => {
if(collected.first().content == 'cancel'){
message.reply('Command cancelled.')
}
console.log('collecred :' + collected.first().content)
}).catch(() => {
message.reply('You took too long! Goodbye!')
});发布于 2020-07-22 13:45:02
它的工作方式与在TextChannel中基本相同,
此外,在您的选项中,您需要设置属性errors,并将时间定义为错误。
//msg.author.dmChannel doesn't always exist and if it doesn't it will throw an error
//so call <User>.createDM() first if you don't know it exists yet
msg.author.dmChannel.awaitMessages({ max: 1, time: 10000, errors: ["time"] })
.then(async collected => {
})
.catch(() => {});https://discord.js.org/#/docs/main/stable/class/DMChannel?scrollTo=awaitMessages
https://stackoverflow.com/questions/63023824
复制相似问题