How to remove a bot after a given time(days).

so I'm making a little bot called "Prison". All it does is adds a command /jail which takes two arguments, username and time(days). I want the user to get the jailed role whenever I run the command and it automatically gets removed after the time given. I'm fairly new to discord.js. I tried doing a setInterval but... It's very self explanatory why it didn't worked, because I can't track the time of however many different users with one setInterval.
5 Replies
d.js toolkit
d.js toolkit2mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
NyR
NyR2mo ago
You'd need to save the the user with their expiry date to a database of sort and then periodically check if it's expired (with something like setInterval or node-cron) And then remove the role if it is
efficient123
efficient1232mo ago
Like i will first calculate at what date the prisoner must be released, and then check every 10 mins for the date and check every object in the database if any release date matches it. If it do it will remove the role for the user, right?
NyR
NyR2mo ago
Something like that, you can check if the current date/time is after the one you have saved and do the necessary actions if it is
efficient123
efficient1232mo ago
Thanks.