#Correct Usage but Still Getting 'Usage' Message

1 messages · Page 1 of 1 (latest)

little citrus
#

That ain't helping anything to solve your problem... send other parts too

#

-# also, hi fellow Filipino/Filipina

cobalt merlin
#

-# Hi

little citrus
#

that's a lot but okay.

#

What command you put

#

Just !tpa deletehome 100

cobalt merlin
cobalt merlin
little citrus
#

How you setup the args?

#

Wtf, I'm asking you and you literally send the file lmdoa

cobalt merlin
# little citrus How you setup the *args*?

This is what you're talking about?

handleHomeSubCommand(player, args) {
    const command = args[1];

    if (!command) {
        player.sendMessage("§c<TPA> Please specify a subcommand. Type '!tpa help' for a list of commands.");
        return;
    }

    switch (command.toLowerCase()) {
        case 'list':
            this.listHomes(player);
            break;

        case 'rename':
            this.renameHome(player, args);
            break;

        case 'delete':
            this.deleteHome(player, args);
            break;

        default:
            const homeNumber = parseInt(command);
            if (!isNaN(homeNumber)) {
                this.teleportHome(player, args);
            } else {
                player.sendMessage("§c<TPA> Unknown home sub-command. Type '!tpa help' for a list of commands.");
            }
            break;
    }
},```
restive comet
#

yes

cobalt merlin
restive comet
#

No i don’t think that’s what he’s on about

#

No it’s not

#

It’s where you get args

#

It’ll be in a chatSend event

#

How do you put your args into an array basically

#

and pass it into parameters etc

little citrus
#
world.beforeEvents.chatSend.subscribe(ev => {
    const { message, sender: player } = ev;

    if (message.startsWith('!tpa')) {
        ev.cancel = true;

        const args = message.split(' ');

        if (args[1] === 'deletehome') {
            if (args.length < 3) {
                player.sendMessage('§c<TPA> Usage: !tpa deletehome <nvalue>');
                return;
            }

            deleteHome(player, args);
        } else {
            player.sendMessage('§c<TPA> Unknown command. Use !tpa deletehome <nvalue>.');
        }
    }
});
#

Kinda like this

little citrus
cobalt merlin
# little citrus ```js world.beforeEvents.chatSend.subscribe(ev => { const { message, sender:...
import { world } from '@minecraft/server';
import { teleportationSystem } from './teleportationSystem/teleportationSystem.js';

world.beforeEvents.chatSend.subscribe((eventData) => {
    const player = eventData.sender;
    let message = eventData.message;

    // Process bypass chat
    if (config.bypassChat) {
        message = processBypassChat(message);
    }

    // Handle teleportation commands
    if (message.startsWith('!tpa')) {
        eventData.cancel = true;
        teleportationSystem.handleCommand(player, message);
        return;
    }

    // Handle custom username display
    if (config.handleChatMessage || config.rank) {
        eventData.cancel = true;
        handleChatMessage(player, message, config);
    }
});```