Skip to content

Terminal Commands

Add custom terminal commands that players can run in the in-game terminal.

Basic Command

typescript
import { Command, RegisterCommand } from "@hotbunny/hackhub-content-sdk";

@RegisterCommand
class PingCommand extends Command {

    CommandName = "myping";
    Description = "Custom ping tool";

    async Run(tools) {
        const args = tools.getArgs();

        if (args.length === 0) {
            tools.printError("Usage: myping <ip>");
            return;
        }

        tools.println(`Pinging ${args[0]}...`);
        await tools.sleep(1000);
        tools.println("Reply received.");
    }

}

Properties

PropertyTypeDescription
CommandNamestringThe command name players type
DescriptionstringHelp text shown in autocomplete
AutocompleteCommandAutoComplete[]Autocomplete hints
PackageNamestringPackage name (if installable via apt install)

The Run Method

Run(tools) is called when the player executes the command. It receives a tools object with helper methods.

Tools API

MethodDescription
tools.getArgs()Get command arguments as string[]
tools.println(text)Print a line to the terminal
tools.printError(text)Print an error message
tools.printWarning(text)Print a warning message
tools.printSuccess(text)Print a success message
tools.sleep(ms)Wait for a duration
tools.clear()Clear the terminal

Autocomplete

Define autocomplete hints to help players:

typescript
@RegisterCommand
class ScanCommand extends Command {

    CommandName = "modscan";
    Description = "Scan a target for vulnerabilities";

    Autocomplete = [
        { label: "modscan", type: "STRING" },
        { label: "<target-ip>", type: "IP" },
        { label: "--deep", type: "FLAG" },
    ];

    async Run(tools) {
        const args = tools.getArgs();
        tools.println(`Scanning ${args[0] || "..."}...`);
        await tools.sleep(2000);
        tools.printSuccess("Scan complete. No vulnerabilities found.");
    }

}

Autocomplete Types

TypeDescription
STRINGGeneric text
IPIP address
FLAGA flag like --verbose
FILEFile path
DIRECTORYDirectory path
USERUsername

Installable Commands

If you set PackageName, the command must be installed via apt install before use:

typescript
@RegisterCommand
class HackTool extends Command {

    CommandName = "hacktool";
    Description = "Advanced hacking toolkit";
    PackageName = "hacktool";

    async Run(tools) {
        tools.println("HackTool v1.0 loaded.");
    }

}

HotBunny Interactive Entertainment Inc.