Browse Source

Add Bot.botInstancesSequence

Him188 5 years ago
parent
commit
a5f9504b10
1 changed files with 9 additions and 0 deletions
  1. 9 0
      mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt

+ 9 - 0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt

@@ -84,6 +84,15 @@ abstract class Bot internal constructor(
         val botInstances: List<Bot>
             get() = _instances.asSequence().mapNotNull { it.get() }.toList()
 
+        /**
+         * 复制一份此时的 [Bot] 实例列表.
+         */
+        @MiraiExperimentalAPI
+        @SinceMirai("1.1.0")
+        @JvmStatic
+        val botInstancesSequence: Sequence<Bot>
+            get() = _instances.asSequence().mapNotNull { it.get() }
+
         /**
          * 遍历每一个 [Bot] 实例
          */