'Make setTimeout() work after closing and opening an application

So atm I'm working on a Discord.js bot and have a command to ban people. The issue is if I turn the bot off and on again all the setTimeouts reset. So say, if I were to ban someone for a week, turn the bot off and on in between there, they will never automatically be unbanned.

setTimeout(function () {
                    memberTarget.roles.remove(bannedRole);
                }, ms(args[1]));

What other way could I use for it to remember to unban everyone after the bot has been turned on again?



Solution 1:[1]

You need to use database or data persist

Store bans data to database/data persist then set worker to check for unban (expiry).

Database https://www.tutorialsteacher.com/nodejs/data-access-in-nodejs

Data Persist https://www.npmjs.com/package/node-persist

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shahnawaz Kadari