Javascript 如何让discord bot等待回复5分钟,然后发送消息?使用discordjs
我正在使用Discord js制作一个Discord机器人。bot的作用是在个人消息中向用户发送消息,然后等待用户响应5分钟。如果用户没有将任何内容发送回成员,则bot会发送一条消息,说明请求已被拒绝,因为他们没有发送任何电子邮件id。我正在使用discord.js collector npm包获取消息并将其发送给用户。我遇到的问题是,如果用户没有键入任何内容,bot将在30秒后向用户发回回复。我不想那样。我希望机器人在发送请求被拒绝消息之前等待5分钟。下面是我的代码的样子Javascript 如何让discord bot等待回复5分钟,然后发送消息?使用discordjs,javascript,node.js,discord,discord.js,bots,Javascript,Node.js,Discord,Discord.js,Bots,我正在使用Discord js制作一个Discord机器人。bot的作用是在个人消息中向用户发送消息,然后等待用户响应5分钟。如果用户没有将任何内容发送回成员,则bot会发送一条消息,说明请求已被拒绝,因为他们没有发送任何电子邮件id。我正在使用discord.js collector npm包获取消息并将其发送给用户。我遇到的问题是,如果用户没有键入任何内容,bot将在30秒后向用户发回回复。我不想那样。我希望机器人在发送请求被拒绝消息之前等待5分钟。下面是我的代码的样子 message.r
message.reply("Please check your DM to verify your email id");
const filter = (m) => m.author.id === message.author.id;
const botMessage = await message.author.send("Enter your registered email Id please?");
const userMessage = await MessageCollector.asyncQuestion({
botMessage,
user: message.author.id,
time:300000 // milliseconds
}).catch(()=>{
message.author.send("Request Denied because you did not responded with a registerd email ID. You can request again!");
return 0;
});
我还使用discordjs库实现了自己的参数,比如idle,但是我仍然得到了错误。下面是我的代码在那里的外观
message.reply("Please check your DM to verify your email id");
const filter = (m) => m.author.id === message.author.id;
const botMessage = await message.author.send("Enter your registered email Id please?");
const userMessage = await MessageCollector.asyncQuestion({
botMessage,
user: message.author.id,
idle:300000 // milliseconds
}).catch(()=>{
message.author.send("Request Denied because you did not responded with a registerd email ID. You can request again!");
return 0;
});
如果有人能告诉我哪里出错,那就太好了。您使用的函数没有时间或空闲属性。
相反,它具有类型为的collectorOptions
因此,您应该使用asyncQuestion定义的collectorOptions,并将其与您的时间选项一起传递到对象中,然后您的计时器应该按预期工作
const userMessage = await MessageCollector.asyncQuestion({
botMessage,
user: message.author.id,
collectorOptions: { time: 300000 }
}).catch(() => {
// catch code here...
});