centralwtf Posted May 3, 2021 Share Posted May 3, 2021 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 ========================================== Link to comment Share on other sites More sharing options...
0 CoolProgrammer Posted May 4, 2021 Share Posted May 4, 2021 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. 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 More sharing options...
0 centralwtf Posted May 4, 2021 Author Share Posted May 4, 2021 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 ========================================== Link to comment Share on other sites More sharing options...
0 CoolProgrammer Posted May 4, 2021 Share Posted May 4, 2021 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. 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 More sharing options...
0 The_blue_sky555 Posted July 14, 2021 Share Posted July 14, 2021 OK but where i can but this New Text Document.txt Link to comment Share on other sites More sharing options...
Question
centralwtf
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!
IGN✦ centralwtf
Gender★ he/him
==========================================
Owner★ Boxable, NetherBox, FishHype
==========================================
Joined★ 22.07.2019
Member -> VIP ★ 29.04.2020
==========================================
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now