diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt index fe62c0665..029e8498a 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt @@ -169,8 +169,11 @@ class Bot(val account: BotAccount, val logger: MiraiLogger) : CoroutineScope { private val _instances: MutableList = mutableListOf() private val instanceLock: Mutex = Mutex() - val instances: List get() = _instances + private val instances: List get() = _instances + suspend fun instanceWhose(qq: UInt) = instanceLock.withLock { + instances.first { it.qqAccount == qq } + } internal suspend fun addInstance(bot: Bot) = instanceLock.withLock { _instances += bot