a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Shared / Command
Command(
commandName): (target,propertyKey,descriptor) =>void
A decorator to register a method as a command with a specified name.
This decorator uses the RegisterCommand function to register the method as a command handler
and stores metadata about the command name using reflect-metadata.
• commandName: string
The name of the command to register.
Function
• target: unknown
• propertyKey: string
• descriptor: PropertyDescriptor
void
class MyCommands {
@Command('sayHello')
helloCommand() {
console.log('Hello, world!');
}
}
In the above example, the helloCommand method is registered as a command with the name sayHello.
Error if the command registration fails.
The RegisterCommand function is expected to handle the command registration logic
and reflect-metadata is used for storing and retrieving metadata associated with the command.