我有一个!trivia命令,该命令具有4个功能,在函数内部,我具有一个.then()
函数和.setTimeout()
。问题在于,一旦有人触发了该命令,它只会在有人说“!stop”时停止。如果没有人在5分钟内在该频道中键入内容,该如何使其停止?
答案 0 :(得分:0)
let userUsingTheCommand = "<USER_ID>";
let filter = msg => msg.author.id = userUsingTheCommand;
// Errors: ['time'] treats ending because of the time limit as an error
function wait() {
channel.awaitMessages(filter, {
max: 1,
time: 60000 * 5,
errors: ['time']
})
.then(wait)
.catch(() => {
console.log("Time to stop!");
});
}