I am trying to make this mineflayer bot attack specific players mentioned in chat

923 Views Asked by At

Is there a way to give the bot a command, and type someone's username in chat with the command, for example, "attack (username)", and have it attack that player?

1

There are 1 best solutions below

0
On
const target = bot.players[username] ? bot.players[username].entity : null;
if(!target){
     //action if requested player doesn't exist
}
bot.attack(target);