Возможно что-то такое
const session = {
unanswered: [],
isRedirect: true,
date: 1545762010253
};
const intervalID = null;
const checkSession = () => {
if (Date.now() > session.date) {
session.isRedirect = false;
delete session.unanswered;
}
};
client.on('message', async (msg) => {
if (session.isRedirect) {
сlearInterval(intervalID);
await fetch(...);
session.unanswered.push(msg.id);
intervalID = setInterval(checkSession, 100);
} else {
session.isRedirect = true;
session.unanswered = [];
session.date = Date.now() + 60 * 1000;
}
});
intervalID = setInterval(checkSession, 100);