#I can't find the error Help me please

1 messages · Page 1 of 1 (latest)

lone ocean
#
world.beforeEvents.chatSend.subscribe((eventData) => {
    const player = eventData.sender;
    if (!player.hasTag('admin')) return;
    let playerCmds = ["!kick"];
    switch (playerCmds.includes(eventData.message.split(' ')[0]) ? eventData.message.split(' ')[0] : eventData.message) {
        case '!kick':
            eventData.cancel = true;
            let otherPlayerName = eventData.message.split(' ').slice(1).join(' ');
            let otherPlayer;
            for (const player of world.getPlayers()) {
                if (player.name == otherPlayerName) otherPlayer = player;
            }
            system.run(() => {
                if (!otherPlayer) return player.runCommand(`tellraw @s {"rawtext":[{"text":"§l§4[Serveur]§cLe joueur §e${otherPlayerName}§c n'est pas connecté!"}]}`);
                otherPlayer.runCommand(`tellraw @a{"rawtext":[{"text":"§l§4[Serveur]§c${otherPlayerName} a été expulser par ${player.name}!"}]}`);
                player.runCommand(`kick ${otherPlayer}`);
            })
            break;
        default: break;
    }
})
#
player.runCommand(`kick ${otherPlayer}`);

according to minecraft the error is in this line

spark terrace
#

you can't find error but you already written it here

lone ocean
#

I haven't already asked

spark terrace
#

player is object thats why its saying Object object

#

commands are strings so you dont need player but playerName

lone ocean
#

ok thank you i managed to fix my error
sorry i didn't search enough on my own

#

I'm a beginner so I'm not necessarily very good

spark terrace
#

good luck

lone ocean
#

thank you for your advice