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) {
}
}

See also

Constructors

Link copied to clipboard
fun RawCommand(    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
open suspend fun CommandContext.onCommand(args: MessageChain)
open suspend fun CommandSender.onCommand(args: MessageChain)

在指令被执行时调用.

Properties

Link copied to clipboard
open override val description: String

指令描述, 用于显示在 BuiltInCommands.HelpCommand

Link copied to clipboard
open override val overloads: List<@JvmWildcard CommandSignature>

指令可能的参数列表.

Link copied to clipboard
open override val owner: CommandOwner

指令拥有者. 通常建议使用插件主类.

Link copied to clipboard
open override val permission: Permission

为此指令分配的权限.

Link copied to clipboard
open override val prefixOptional: Boolean = false

true 时表示 指令前缀 可选

Link copied to clipboard
open override val primaryName: String

主指令名.

Link copied to clipboard
open override val secondaryNames: Array<out String>

次要指令名.

Link copied to clipboard
open override val usage: String

用法说明, 用于发送给用户