#My chatsend event isnt working

1 messages · Page 1 of 1 (latest)

maiden vault
#
world.beforeEvents.chatSend.subscribe((eventData) => {
    const player = eventData.sender;
    switch (eventData.message) {
        case '?accept':
            eventData.cancel = true;
                player.runCommandAsync('tp @p[tag=tpr] @s[tag=tpa]') && player.runCommandAsync('tag @a remove tpa') && player.runCommandAsync('tag @a remove tpr');
            break;
    }
});```
idle relicBOT
#

Description
A script that detects a chat message then the script handles all custom command inputs and outputs

Credits
These scripts were written by Smell of Curry

sharp breach
#

you don't need the && statements

maiden vault
#

oh ok

#
import { sendPlayerMessage, config } from '../../../config';
export function acceptHelp(player) {
    sendPlayerMessage(player, `§7[§c!§7]: -- §bSaturn Lifesteal Help Page §7-- §bAccept§7
> Accept a tp request

> Usage: ${config.prefix}accept

> Examples: 
${config.prefix}accept
`);
}
new Command({
    name: 'accept',
    code({ player, args }) {
        if (!player.hasTag(`tpa`))
            return sendPlayerMessage(player, `§cAccepted tp request!`);
            player.runCommandAsync('tp @p[tag=tpr] @s[tag=tpa]')
            player.runCommandAsync('tag @a remove tpa') && player.runCommandAsync('tag @a remove tpr');
    }
});```
maiden vault
#

but still isnt working

#

wait

#

i got it working but it sends it in chat still

snow nimbus
#

you have to cancel it

#

so eventData.cancel = true; as an example

maiden vault
#

alright i will test it

#
export { Command };
export const commands = Command.commands;
world.beforeEvents.chatSend.subscribe(data => {
    if (data.message.startsWith("!")) {
        data.cancel = true;
        const args = data.message.slice(config.prefix.length).toLowerCase().split(/\s+/g);
        const command = args.shift();```
maiden vault
snow nimbus
#

whats that command do

#

try putting data.cancel = true after those two