Fix uninitialized property exception when Bot.closed called before Bot.login

This commit is contained in:
Him188 2021-02-03 19:23:12 +08:00
parent 9597a70f58
commit 012d9d6e71

View File

@ -329,14 +329,16 @@ internal abstract class AbstractBot<N : BotNetworkHandler> constructor(
return
}
if (this.network.areYouOk()) {
GlobalScope.launch {
runCatching { BotOfflineEvent.Active(this@AbstractBot, cause).broadcast() }.exceptionOrNull()
?.let { logger.error(it) }
if (::_network.isInitialized) {
if (this.network.areYouOk()) {
GlobalScope.launch {
runCatching { BotOfflineEvent.Active(this@AbstractBot, cause).broadcast() }.exceptionOrNull()
?.let { logger.error(it) }
}
}
}
this.network.close(cause)
this.network.close(cause)
}
if (supervisorJob.isActive) {
if (cause == null) {