Skip to main content

Overview

Commands allow you to add custom chat-based functionality to LiquidBounce. Script commands integrate with the built-in command system and support parameters, subcommands, and autocompletion.

Basic Command Structure

Use script.registerCommand() to create a new command:
var script = registerScript({
    name: "MyCommands",
    version: "1.0.0",
    authors: ["Developer"]
});

script.registerCommand({
    name: "greet",
    aliases: ["hello", "hi"],
    onExecute: function() {
        Client.displayChatMessage("§aHello, World!");
    }
});
Usage: .greet, .hello, or .hi

Command Configuration

name
string
required
The primary command name (used as .name)
aliases
string[]
Optional alternative names for the command
parameters
Parameter[]
Array of parameter definitions (see Parameters)
subcommands
Command[]
Nested subcommands (see Subcommands)
onExecute
function
Handler function called when command is executed
hub
boolean
If true, shows subcommand list when executed without arguments

Parameters

Add parameters to accept user input:
script.registerCommand({
    name: "say",
    parameters: [
        {
            name: "message",
            required: true
        }
    ],
    onExecute: function(message) {
        Client.displayChatMessage("§7You said: " + message);
    }
});
Usage: .say Hello everyone!

Parameter Options

name
string
required
Parameter name (used for display and debugging)
required
boolean
Whether this parameter must be provided (default: false)
vararg
boolean
If true, captures all remaining arguments as one string (default: false)
getCompletions
function
Function that returns autocomplete suggestions:
getCompletions: function(begin, args) {
    return ["option1", "option2", "option3"];
}
validate
function
Custom validation function:
validate: function(param) {
    var num = parseInt(param);
    if (isNaN(num)) {
        return { accept: false, error: "Must be a number" };
    }
    return { accept: true, value: num };
}

Parameter Examples

script.registerCommand({
    name: "teleport",
    parameters: [
        { name: "x", required: true },
        { name: "y", required: true },
        { name: "z", required: true }
    ],
    onExecute: function(x, y, z) {
        var player = mc.player;
        if (player) {
            player.setPos(parseFloat(x), parseFloat(y), parseFloat(z));
            Client.displayChatMessage("§aTeleported!");
        }
    }
});
Usage: .teleport 100 64 200

Subcommands

Create complex command hierarchies:
script.registerCommand({
    name: "config",
    hub: true,
    subcommands: [
        {
            name: "save",
            onExecute: function() {
                Client.configSystem.save();
                Client.displayChatMessage("§aConfig saved!");
            }
        },
        {
            name: "load",
            onExecute: function() {
                Client.configSystem.load();
                Client.displayChatMessage("§aConfig loaded!");
            }
        },
        {
            name: "reset",
            parameters: [
                { name: "confirm", required: true }
            ],
            onExecute: function(confirm) {
                if (confirm === "yes") {
                    Client.displayChatMessage("§cConfig reset!");
                } else {
                    Client.displayChatMessage("§eUse 'config reset yes' to confirm");
                }
            }
        }
    ]
});
Usage:
  • .config - Shows available subcommands (because hub: true)
  • .config save - Saves configuration
  • .config load - Loads configuration
  • .config reset yes - Resets with confirmation

Complete Examples

Example 1: Info Command

var script = registerScript({
    name: "InfoCommands",
    version: "1.0.0",
    authors: ["Developer"]
});

script.registerCommand({
    name: "info",
    aliases: ["i"],
    hub: true,
    subcommands: [
        {
            name: "position",
            aliases: ["pos"],
            onExecute: function() {
                var player = mc.player;
                if (!player) {
                    Client.displayChatMessage("§cNot in game!");
                    return;
                }
                var pos = player.position();
                Client.displayChatMessage(
                    "§7Position: §f" + 
                    pos.x.toFixed(2) + " " + 
                    pos.y.toFixed(2) + " " + 
                    pos.z.toFixed(2)
                );
            }
        },
        {
            name: "health",
            aliases: ["hp"],
            onExecute: function() {
                var player = mc.player;
                if (!player) {
                    Client.displayChatMessage("§cNot in game!");
                    return;
                }
                var health = player.getHealth();
                var maxHealth = player.getMaxHealth();
                Client.displayChatMessage(
                    "§7Health: §c" + health.toFixed(1) + 
                    "§7/§c" + maxHealth.toFixed(1)
                );
            }
        },
        {
            name: "ping",
            onExecute: function() {
                var connection = mc.getConnection();
                if (!connection) {
                    Client.displayChatMessage("§cNot connected to server!");
                    return;
                }
                var latency = connection.getLatency();
                Client.displayChatMessage("§7Ping: §a" + latency + "ms");
            }
        }
    ]
});

Example 2: Module Control Command

script.registerCommand({
    name: "module",
    aliases: ["mod", "m"],
    hub: true,
    subcommands: [
        {
            name: "toggle",
            aliases: ["t"],
            parameters: [
                {
                    name: "moduleName",
                    required: true,
                    getCompletions: function(begin) {
                        var modules = Client.moduleManager.getModules();
                        return modules
                            .map(function(m) { return m.name; })
                            .filter(function(name) {
                                return name.toLowerCase().startsWith(begin.toLowerCase());
                            });
                    }
                }
            ],
            onExecute: function(moduleName) {
                var module = Client.moduleManager.getModule(moduleName);
                if (!module) {
                    Client.displayChatMessage("§cModule not found: " + moduleName);
                    return;
                }
                module.enabled = !module.enabled;
                var state = module.enabled ? "§aenabled" : "§cdisabled";
                Client.displayChatMessage("§7Module " + moduleName + " " + state);
            }
        },
        {
            name: "list",
            aliases: ["l"],
            parameters: [
                {
                    name: "category",
                    required: false,
                    getCompletions: function() {
                        return ["Combat", "Movement", "Player", "World", "Render", "Misc"];
                    }
                }
            ],
            onExecute: function(category) {
                var modules = Client.moduleManager.getModules();
                if (category) {
                    modules = modules.filter(function(m) {
                        return m.category.name === category;
                    });
                }
                Client.displayChatMessage("§7Modules: " + modules.length);
                modules.forEach(function(m) {
                    var state = m.enabled ? "§a✓" : "§c✗";
                    Client.displayChatMessage("  " + state + " §f" + m.name);
                });
            }
        }
    ]
});

Accessing Arguments

Parameters are passed to onExecute in order:
script.registerCommand({
    name: "example",
    parameters: [
        { name: "first", required: true },
        { name: "second", required: false },
        { name: "rest", vararg: true }
    ],
    onExecute: function(first, second, rest) {
        Client.displayChatMessage("First: " + first);
        Client.displayChatMessage("Second: " + (second || "none"));
        Client.displayChatMessage("Rest: " + (rest || "none"));
    }
});

Best Practices

Always validate and handle invalid input gracefully:
onExecute: function(param) {
    if (!param) {
        Client.displayChatMessage("§cUsage: .command <param>");
        return;
    }
    // Process valid input
}
Always inform the user what happened:
Client.displayChatMessage("§aOperation successful!");
// or
Client.displayChatMessage("§cOperation failed: reason");
For commands with many subcommands, set hub: true to show help:
{
    name: "mycommand",
    hub: true,
    subcommands: [...]
}
Provide getCompletions for better user experience:
getCompletions: function(begin, args) {
    return possibleValues.filter(function(v) {
        return v.startsWith(begin);
    });
}

Next Steps

API Reference

Explore available utilities and functions

Creating Modules

Learn about creating custom modules

Build docs developers (and LLMs) love