Skip to content

Usage

Types are primarily used when defining arguments - they specify what type the argument requires.

Let’s say you have a kill command that requires a Player argument:

import { CommanderType } from "@rbxts/commander";
@Commander()
class KillCommand {
@Command({
name: "kill",
description: "Kills a player",
arguments: [
{
name: "player",
description: "Player to kill",
type: CommanderType.Player, // Specify the name of the type here
},
],
})
kill(interaction: CommandInteraction, player: Player) {
const humanoid = player.Character?.FindFirstChildOfClass("Humanoid");
if (humanoid === undefined) {
interaction.error(`${player.Name} does not have a Humanoid`);
return;
}
humanoid.Health = 0;
interaction.reply(`Successfully killed ${player.Name}`);
}
}