From 97615e5d7ef0f7cc27820c0d03b235f91fd2b766 Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 20 Feb 2020 22:19:54 +0800 Subject: [PATCH] Add docs --- .../kotlin/net.mamoe.mirai/contact/Permission.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Permission.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Permission.kt index ac1137744..baeb5951f 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Permission.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Permission.kt @@ -9,6 +9,7 @@ package net.mamoe.mirai.contact +import net.mamoe.mirai.Bot import net.mamoe.mirai.utils.MiraiExperimentalAPI @@ -68,7 +69,6 @@ inline fun Member.isAdministrator(): Boolean = this.permission.isAdministrator() inline fun Member.isOperator(): Boolean = this.permission.isOperator() - /** * 权限不足 */ @@ -77,6 +77,11 @@ expect class PermissionDeniedException : IllegalStateException { constructor(message: String?) } +/** + * 要求 [Bot] 在这个群里的权限为 [required], 否则抛出异常 [PermissionDeniedException] + * + * @throws PermissionDeniedException + */ @UseExperimental(MiraiExperimentalAPI::class) inline fun Group.checkBotPermission( required: MemberPermission, @@ -89,6 +94,11 @@ inline fun Group.checkBotPermission( } } +/** + * 要求 [Bot] 在这个群里的权限为 [管理员或群主][MemberPermission.isOperator], 否则抛出异常 [PermissionDeniedException] + * + * @throws PermissionDeniedException + */ @UseExperimental(MiraiExperimentalAPI::class) inline fun Group.checkBotPermissionOperator( lazyMessage: () -> String = {