Skip to content
Centurion

Decorators

@Register

Marks a class for registration. You can also register groups from here.

The next time register is called, any commands within the class will be registered. Any groups defined in the decorator will be registered before the commands.

Usage

@Register({
groups: [
{
name: "example",
description: "Example group"
}
]
})
export class MyCommand {
// ...
}

@Command(options)

Defines a command.

Parameters:

  • options: CommandOptions The command’s options.

Usage

@Register()
class ExampleCommand {
@Command({
name: "example",
description: "An example command",
})
example() {
// ...
}
}

@Group(groups)

Assigns a command to one or more groups.

When a class is decorated with this decorator, all commands within the class will be assigned to the group.

Parameters:

  • groups: ...string[] The groups to assign to the command.

Usage

@Command({
name: "view",
description: "Displays info about a player",
})
@Group("info", "player")
// Command is executable through "info player view"
viewPlayer() {}
@Command({
name: "view",
description: "Displays info about the server",
})
@Group("info", "server")
// Command is executable through "info server view"
viewServer() {}

@Guard(guards)

Assigns one or more guards to a command.

When a class is decorated with this decorator, the provided guard(s) will be assigned to all commands within the class.

Parameters:

  • guards: ...CommandGuard[] The guards to assign to the command.

Usage

@Command({
name: "ban",
description: "Bans a player",
})
@Guard(isAdmin)
ban() {}

CommandOptions

  • name: string - The name of the command.
  • aliases: string[]? - An array of aliases for the command.
  • description: string? - The command’s description.
  • arguments: ArgumentOptions[]? - The command’s arguments.

ArgumentOptions

  • name: string - The name of the argument.
  • description: string - The argument’s description.
  • type: string - The argument’s type. Must be the name of a registered type.
  • numArgs: number | "rest" - The number of inputs the argument should accept. This will produce an array of values. If set to rest, it will accept all remaining arguments, but can only be used on the last argument.
  • optional: boolean? - Whether the argument is optional.
  • suggestions: string[]? - An array of suggestions for the argument. These will be added to the suggestions returned by the argument’s type.