#How can i auto activate the current date when it matches a specific timestamp?
19 messages · Page 1 of 1 (latest)
- 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!
What does activating a date mean in this context?
1698333071068 I want to run the code when the timestamp is equal to the current (Date.now()) timestamp, how can i do it?
I've done something similiar in the past setting up a setInterval checking if the date has passed every 10 minutes. Check the line with "setInterval".
https://raw.githubusercontent.com/VioletFlare/rank/master/src/Commands/Leaderboard.js
Although nowadays i'd prefer node-cron.
If the date in your case could be expressed as a cron task you might check out node-cron package.
I know how to do it with setInvertal but i don't want this because it is delayed, i wanted the code inside the { } to run as soon as it expires
I will examine node-cron thanks
Use a setTimeout then
Put the date into the part which’ll end when it reaches said time
The times i will put will be between 1 hour and 1 month and when this is done by many users, the VPS can crash
How will it crash?
Imo using a setInterval or node-cron checking everything at one time is bad
It was giving an error like BIT count and the bot could not be opened
Having lots of setTimeout running at the same time is worse
Can you explain how? Genuinely curious
How do you think setTimeout works?
No idea, really
If you set 20 12h setTimeout, you will get the same error
Then read up on it, not gonna explain something you can find plenty of information on yourself