mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
PermissionIdValueArgumentParser: Parse "*" as RootPermission.id for convenience
This commit is contained in:
parent
8683e88892
commit
5bd6182a17
@ -18,6 +18,7 @@ import net.mamoe.mirai.console.internal.command.fuzzySearchMember
|
||||
import net.mamoe.mirai.console.permission.AbstractPermitteeId
|
||||
import net.mamoe.mirai.console.permission.PermissionId
|
||||
import net.mamoe.mirai.console.permission.PermitteeId
|
||||
import net.mamoe.mirai.console.permission.RootPermission
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.message.data.*
|
||||
|
||||
@ -337,6 +338,7 @@ public object ExistingMemberValueArgumentParser : InternalCommandValueArgumentPa
|
||||
public object PermissionIdValueArgumentParser : InternalCommandValueArgumentParserExtensions<PermissionId>() {
|
||||
override fun parse(raw: String, sender: CommandSender): PermissionId {
|
||||
return kotlin.runCatching { PermissionId.parseFromString(raw) }.getOrElse {
|
||||
if (raw == "*") return RootPermission.id // for convenience
|
||||
illegalArgument("无法解析 $raw 为权限 ID.")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user