RawCommand
abstract class RawCommand(val owner: CommandOwner, val primaryName: String, val secondaryNames: String, val usage: String = "<no usages given>", val description: String = "<no descriptions given>", parentPermission: Permission = owner.parentPermission, val prefixOptional: Boolean = false) : Command
无参数解析, 只会接收原消息链的指令. Java 查看 JRawCommand.
object MyCommand : RawCommand(
MyPluginMain, "name", // 使用插件主类对象作为指令拥有者;设置主指令名为 "name"
// 可选:
"name2", "name3", // 增加两个次要名称
usage = "/name arg1 arg2", // 设置用法,将会在 /help 展示
description = "这是一个测试指令", // 设置描述,将会在 /help 展示
prefixOptional = true, // 设置指令前缀是可选的,即使用 `test` 也能执行指令而不需要 `/test`
) {
override suspend fun CommandContext.onCommand(args: MessageChain) {
}
}
Content copied to clipboard
See also
Constructors
Link copied to clipboard
constructor(owner: CommandOwner, primaryName: String, vararg secondaryNames: String, usage: String = "<no usages given>", description: String = "<no descriptions given>", parentPermission: Permission = owner.parentPermission, prefixOptional: Boolean = false)
Functions
Link copied to clipboard
inline suspend fun Command.execute(sender: CommandSender, vararg arguments: Message = emptyArray(), checkPermission: Boolean = true): CommandExecuteResult
inline suspend fun Command.execute(sender: CommandSender, arguments: String = "", checkPermission: Boolean = true): CommandExecuteResult
执行一个确切的指令
Link copied to clipboard
Link copied to clipboard
在指令被执行时调用.
Link copied to clipboard
Properties
Link copied to clipboard
获取所有指令名称 (包含 primaryName 和 secondaryNames).
Link copied to clipboard
指令描述, 用于显示在 BuiltInCommands.HelpCommand
Link copied to clipboard
Link copied to clipboard
指令可能的参数列表.
Link copied to clipboard
指令拥有者. 通常建议使用插件主类.
Link copied to clipboard
为此指令分配的权限.
Link copied to clipboard
为 true
时表示 指令前缀 可选
Link copied to clipboard
主指令名.
Link copied to clipboard
次要指令名.