Update docs

This commit is contained in:
Him188 2021-01-14 18:05:33 +08:00
parent b49894a4f1
commit 3b6b7ad377

View File

@ -123,13 +123,14 @@ public interface Bot : CoroutineScope, ContactOrBot, UserOrBot {
/**
* [对方 QQ 号码][id] 获取一个好友对象, 在获取失败时返回 `null`.
* [id] [Bot.id] 相同时返回 [Bot.asFriend]
* [id] [Bot.id] 相同时返回 [Bot.asFriend].
*/
public fun getFriend(id: Long): Friend? =
friends.firstOrNull { it.id == id } ?: if (id == this.id) asFriend else null
/**
* [对方 QQ 号码][id] 获取一个好友对象, 在获取失败时抛出 [NoSuchElementException].
* [id] [Bot.id] 相同时返回 [Bot.asFriend].
*/
public fun getFriendOrFail(id: Long): Friend = getFriend(id) ?: throw NoSuchElementException("friend $id")