#Correct Usage but Still Getting 'Usage' Message
1 messages · Page 1 of 1 (latest)
-# Hi
I did !tpa deletehome 1
Wait what, let me try.
Noo, I'm just asking lmao
How you setup the args?
Wtf, I'm asking you and you literally send the file lmdoa
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;
}
},```
yes
-# (Sorry for late response)
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
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
Yes ²
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);
}
});```