Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
I am making a mineflayer pvp bot but it only attacks once

I am trying to make a pvp minecraft bot using mineflayer in javascript. This is my function for if the bot is requested to pvp:

bot.loadPlugin(pvp)
bot.on('chat', (username, message) =>{
if (message === 'fight me') {
    const player = bot.players[username]

    if (!player) {
      bot.chat("I can't see you.")
      return
    }
    bot.chat("Get ready to PvP in 10 seconds!")
    const sword = bot.inventory.items().find(item => item.name.includes('sword'))
    if (sword) bot.equip(sword, 'hand')
    const shield = bot.inventory.items().find(item => item.name.includes('shield'))
    if (shield) bot.equip(shield, 'off-hand')
   
    sleep(1500).then(() => {
    
    beeingAlive()
    bot.chat(`/tp notbreadbutter ${username}`)
    bot.pvp.attack(player.entity)})
    
  }

  if (message === 'stop') {
    bot.pvp.stop()
    
  }})

I want the bot to know when the player gets killed. I also want the bot to know if the bot itself gets killed. How should i modify my code?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!