How do you disconnect your bot after some time of inactivity? #1886
-
I don't know how to do this correctly |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I don't think there is direct support for this, but it is possible if you know how to multithread. Whenever someone uses a bot command, you can set an AtomicLong to the timestamp it was last used at, and then have another thread that checks if its been a while since a command was used every so often (You can use a ScheuledExectuorService to make it easier to check). |
Beta Was this translation helpful? Give feedback.
-
When you say "disconnect your bot", what do you mean? You need to provide more information. |
Beta Was this translation helpful? Give feedback.
I don't think there is direct support for this, but it is possible if you know how to multithread. Whenever someone uses a bot command, you can set an AtomicLong to the timestamp it was last used at, and then have another thread that checks if its been a while since a command was used every so often (You can use a ScheuledExectuorService to make it easier to check).