diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageChain.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageChain.kt index a9fd4190d..5172ecb59 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageChain.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/MessageChain.kt @@ -38,11 +38,13 @@ interface MessageChain : Message, MutableList { * * @param key 由各个类型消息的伴生对象持有. 如 [PlainText.Key] */ - @Suppress("UNCHECKED_CAST") operator fun get(key: Message.Key): M = first(key) } +/** + * 提供一个类型的值. 若不存在则会抛出异常 [NoSuchElementException] + */ inline operator fun MessageChain.getValue(thisRef: Any?, property: KProperty<*>): T = this.first() as T /**