mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 18:40:15 +08:00
Add "command." prefix to command permissions
This commit is contained in:
parent
9139d62a7c
commit
6f7cc1a78d
@ -20,7 +20,6 @@ import net.mamoe.mirai.console.internal.command.CommandManagerImpl
|
|||||||
import net.mamoe.mirai.console.internal.command.CommandManagerImpl.allRegisteredCommands
|
import net.mamoe.mirai.console.internal.command.CommandManagerImpl.allRegisteredCommands
|
||||||
import net.mamoe.mirai.console.internal.util.runIgnoreException
|
import net.mamoe.mirai.console.internal.util.runIgnoreException
|
||||||
import net.mamoe.mirai.console.permission.Permission
|
import net.mamoe.mirai.console.permission.Permission
|
||||||
import net.mamoe.mirai.console.permission.PermissionId
|
|
||||||
import net.mamoe.mirai.console.permission.PermissionService
|
import net.mamoe.mirai.console.permission.PermissionService
|
||||||
import net.mamoe.mirai.console.permission.PermissionService.Companion.denyPermission
|
import net.mamoe.mirai.console.permission.PermissionService.Companion.denyPermission
|
||||||
import net.mamoe.mirai.console.permission.PermissionService.Companion.findCorrespondingPermissionOrFail
|
import net.mamoe.mirai.console.permission.PermissionService.Companion.findCorrespondingPermissionOrFail
|
||||||
@ -51,7 +50,7 @@ public object BuiltInCommands {
|
|||||||
@ConsoleExperimentalApi
|
@ConsoleExperimentalApi
|
||||||
public val parentPermission: Permission by lazy {
|
public val parentPermission: Permission by lazy {
|
||||||
PermissionService.INSTANCE.register(
|
PermissionService.INSTANCE.register(
|
||||||
PermissionId("console", "*"),
|
ConsoleCommandOwner.permissionId("*"),
|
||||||
"The parent of any built-in commands"
|
"The parent of any built-in commands"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -36,5 +36,5 @@ public interface CommandOwner : PermissionIdNamespace {
|
|||||||
internal object ConsoleCommandOwner : CommandOwner {
|
internal object ConsoleCommandOwner : CommandOwner {
|
||||||
override val parentPermission: Permission get() = BuiltInCommands.parentPermission
|
override val parentPermission: Permission get() = BuiltInCommands.parentPermission
|
||||||
|
|
||||||
override fun permissionId(name: String): PermissionId = PermissionId("console", name)
|
override fun permissionId(name: String): PermissionId = PermissionId("console", "command.$name")
|
||||||
}
|
}
|
@ -88,7 +88,7 @@ internal fun Group.fuzzySearchMember(
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun Command.createOrFindCommandPermission(parent: Permission): Permission {
|
internal fun Command.createOrFindCommandPermission(parent: Permission): Permission {
|
||||||
val id = owner.permissionId(primaryName)
|
val id = owner.permissionId("command.$primaryName")
|
||||||
return PermissionService.INSTANCE[id] ?: PermissionService.INSTANCE.register(id, description, parent)
|
return PermissionService.INSTANCE[id] ?: PermissionService.INSTANCE.register(id, description, parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user