mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-06 17:10:48 +08:00
Update docs
This commit is contained in:
parent
b49894a4f1
commit
3b6b7ad377
@ -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")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user