Jump to content
  • 0

Mineflayer bot


centralwtf

Question

Hello!

I have a question about mineflayer bot. How can I loop one action, for example every 10mins bots types "lol" in chat.

Thank You! ❤️ 

Hello!
IGN✦ centralwtf
Gender★ he/him
==========================================

Owner★ Boxable, NetherBox, FishHype

 ==========================================

Joined★ 22.07.2019

Member -> VIP ★ 29.04.2020

 ==========================================

obraz_2021-04-08_103028.png.8fa96840c599c6ff81febf732163163f.png

 

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
8 hours ago, centralwtf said:

Hello!

I have a question about mineflayer bot. How can I loop one action, for example every 10mins bots types "lol" in chat.

Thank You! ❤️ 

You can achieve that using async promises. Here I've made an example for you, take a look:

// Importing stuff just as usual :3
const mineflayer = require('mineflayer')
const { promisify } = require('util')
const sleep = promisify(setTimeout)

// Create your bot, with connection information.
const bot = mineflayer.createBot({
    host: 'minehut.com',
    port: 25565,
    username: 'email',
    password: 'password',
    version: '1.12.2'
})

// Interval in minutes.
const interval = 10;

// Calling the function when bot logs into the server. Notice the "async".
bot.on('login', async () => sendMessage())

// Loop
async function sendMessage() {
    // Making the bot send a message.
    bot.chat("Beep boop; I'm a bot :3")
    // Waiting for interval times 60000 milliseconds.
    await sleep(interval * 60 * 1000)
    // Self invoking this function.
    sendMessage()
}

Quick Note: If you intend to make an advertisement bot for the lobby, beware that it may get you punished since I've seen people get penalized for that in the past. I'm not too confident but discuss with a staff member before advancing to be on a safer side.

Hello there! If you're reading this, hope you're having a wonderful day!

 

Feel free to contact me via Discord (CoolProgrammer#1920) for any help.

My DMs are always open for help.

You can also message via. forum messages for help.

1604908226_ScreenShot2021-01-28at10_32_28AM.png.2646ad6be239a9d0756a99e8e15602ab.png

Also, don't hesitate to leave a like on my post if I helped you in any way.

Link to comment
Share on other sites

  • 0
1 hour ago, CoolProgrammer said:

You can achieve that using async promises. Here I've made an example for you, take a look:


// Importing stuff just as usual :3
const mineflayer = require('mineflayer')
const { promisify } = require('util')
const sleep = promisify(setTimeout)

// Create your bot, with connection information.
const bot = mineflayer.createBot({
    host: 'minehut.com',
    port: 25565,
    username: 'email',
    password: 'password',
    version: '1.12.2'
})

// Interval in minutes.
const interval = 10;

// Calling the function when bot logs into the server. Notice the "async".
bot.on('login', async () => sendMessage())

// Loop
async function sendMessage() {
    // Making the bot send a message.
    bot.chat("Beep boop; I'm a bot :3")
    // Waiting for interval times 60000 milliseconds.
    await sleep(interval * 60 * 1000)
    // Self invoking this function.
    sendMessage()
}

Quick Note: If you intend to make an advertisement bot for the lobby, beware that it may get you punished since I've seen people get penalized for that in the past. I'm not too confident but discuss with a staff member before advancing to be on a safer side.

Thank You! It works just fine! ❤️ 
DISCLAIMER: It's not for minehut adverisment purposeses.

Hello!
IGN✦ centralwtf
Gender★ he/him
==========================================

Owner★ Boxable, NetherBox, FishHype

 ==========================================

Joined★ 22.07.2019

Member -> VIP ★ 29.04.2020

 ==========================================

obraz_2021-04-08_103028.png.8fa96840c599c6ff81febf732163163f.png

 

 

Link to comment
Share on other sites

  • 0
20 minutes ago, centralwtf said:

Thank You! It works just fine! ❤️ 
DISCLAIMER: It's not for minehut adverisment purposeses.

Nice to hear.

Hello there! If you're reading this, hope you're having a wonderful day!

 

Feel free to contact me via Discord (CoolProgrammer#1920) for any help.

My DMs are always open for help.

You can also message via. forum messages for help.

1604908226_ScreenShot2021-01-28at10_32_28AM.png.2646ad6be239a9d0756a99e8e15602ab.png

Also, don't hesitate to leave a like on my post if I helped you in any way.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...