mirror of
https://github.com/HMCore/Orbot.git
synced 2025-12-12 13:56:18 +00:00
make shutdown hook work correctly
This commit is contained in:
@@ -7,6 +7,8 @@ import net.dv8tion.jda.api.JDA
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed
|
||||
import net.dv8tion.jda.api.entities.User
|
||||
import java.awt.Color
|
||||
import java.sql.Time
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
object Admin {
|
||||
val userId: Long
|
||||
@@ -101,14 +103,14 @@ object Admin {
|
||||
}
|
||||
|
||||
private fun senDevMessageBlocking(messageEmbed: MessageEmbed, fallback: String) {
|
||||
admin = jda!!.retrieveUserById(userId).complete()
|
||||
val devChannel = admin?.openPrivateChannel() ?: kotlin.run {
|
||||
kotlin.io.println(fallback)
|
||||
return
|
||||
}
|
||||
|
||||
devChannel.queue {
|
||||
it.sendMessage(messageEmbed).complete()
|
||||
}
|
||||
devChannel.complete()
|
||||
.sendMessage(messageEmbed).complete()
|
||||
}
|
||||
|
||||
private fun sendDevMessage(messageEmbed: MessageEmbed, fallback: String) {
|
||||
|
||||
@@ -25,7 +25,9 @@ fun main() {
|
||||
Runtime.getRuntime().addShutdownHook(object : Thread() {
|
||||
override fun run() {
|
||||
println("Shutting down...")
|
||||
Admin.printlnBlocking("Shutting down")
|
||||
println("Sending shutdown notice to Admin, waiting 5s...")
|
||||
Admin.println("Shutting down")
|
||||
sleep(5000)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user