#Command Autocompletion

6 messages · Page 1 of 1 (latest)

dark mortar
#

Hello! I am going simple, trying out KubeJS for the first time. I want to ask if it's possible to add autocomplete to custom commands made. For example, a kit command. If I type /kit and then a space, can I make an autocomplete for all available kits?

lethal boneBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

dark mortar
#

Bump.

primal violet
#

a simple example. Not proved of typing issues.
In the KJS wiki, you find some more information


ServerEvents.commandRegistry(e => {
    const { commands: Commands, arguments: Arguments } = e
    e.register(Commands.literal('kit')
        .requires(s => s.hasPermission(2))

            .then(Commands.literal('kit_name_a')
                .requires(s => s.hasPermission(2))
                .executes(c => kitA(c.source.server))
            )

            .then(Commands.literal('kit_name_n')
                .requires(s => s.hasPermission(2))
                .executes(c => kitB(c.source.server))
            )
    )

    function kitA (server) {
        //..your code here
    }

    function kitB (server) {
        //..your code here
    }
})
dark mortar
#

Thank you for the answer! :D