I am currently working on a Discord Bot that should track VC time.
I have a HashMap with the User's ID (long) and if the User is in a VC (boolean).
Now I want to get the time this boolean is true, I first thought of a thread with a loop that adds 1 to an int every second if the boolean is enabled, and A few Listeners that toggle the boolean if a user joins/leaves/mutes/deafens.
Would it be possible to have two methods to named something like enableVc(User user)
and disableVc(User user)
, and if I call disableVc(User user)
, The difference between enableVc(User user)
and now gets saved/added to java.time.Duration
?
(For saving, I would just store the Milliseconds of that Duration with the User's ID in a database)
You can use this to check every 10 seconds if the user is still in the voice and whether he's muted or deafen
new Thread(() -> {
while (true) {
//check if user is in voice & not muted or deafend
//apply coins or something
try {
Thread.sleep(10000); //wait 10 seconds
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.