Discord.js 机器人不';不要尽快收集信息
我正在用Discord.js制作一个应用程序。一切正常,但机器人不会在回答完所有问题后立即收集消息。Discord.js 机器人不';不要尽快收集信息,discord.js,Discord.js,我正在用Discord.js制作一个应用程序。一切正常,但机器人不会在回答完所有问题后立即收集消息。 当收集器的时间用完时,会执行此操作 在回答完所有问题后,如何触发收集器.on('end') const questions =[ 'First Name:', 'Last Name:', 'How old are you:', 'Your email:', 'What is your time zone:',
当收集器的时间用完时,会执行此操作 在回答完所有问题后,如何触发收集器.on('end')
const questions =[
'First Name:',
'Last Name:',
'How old are you:',
'Your email:',
'What is your time zone:',
'Where are you from:',
'What languages are you speaking:',
'Have your ever been punished on our server:',
'On which server your most active on:',
'Have you ever been in a staff team:',
'Tell us about your self:'
]
let counter = 0
const filter = m => m.author.id === message.author.id
const collector = message.author.dmChannel.createMessageCollector(filter, {
max: questions.Lenght,
time: 60000
});
message.author.send(questions[counter++]);
console.log(`1st question has been sent to ${message.author.tag}`);
collector.on('collect', (m) => {
if(counter < questions.length) {
console.log(`sending more questions to ${message.author.tag} until answer them all`);
message.author.send(questions[counter++])
}
})
collector.on('end', (collected) => {
console.log(`collected ${collected.size} messages`);
message.author.send(`Your application has been successfully sent`);
let counter = 0
collected.forEach((value) => {
console.log(questions[counter++], value.content)
})
})
常量问题=[
“名字:”,
'姓:',
“你多大了?”,
'您的电子邮件:',
'您的时区是什么:',
“你从哪里来?”,
“你说什么语言?”,
“您是否曾在我们的服务器上受到过处罚:”,
'您最活跃的服务器是:',
“您是否曾参加过员工团队:”,
“跟我们说说你自己吧:”
]
设计数器=0
const filter=m=>m.author.id==message.author.id
const collector=message.author.dmChannel.createMessageCollector(过滤器{
麦克斯:问题,长度,
时间:60000
});
message.author.send(问题[counter++]);
log(`1个问题已发送到${message.author.tag}`);
收集器.on('collect',(m)=>{
如果(计数器<问题长度){
log(`sending more questions to${message.author.tag},直到全部回答为止`);
message.author.send(问题[counter++])
}
})
collector.on('end',(collected)=>{
log(`collected${collected.size}消息`);
message.author.send(`Your application has successfully send`);
设计数器=0
已收集。forEach((值)=>{
console.log(问题[counter++],value.content)
})
})
您编写了max:questions.lengh
而不是max:questions.length
,其中L
和th