Closed V4nden closed 2 years ago
You have to await all those this.bot.dig(...)
These articles should help you with Promise Rejections: https://flaviocopes.com/javascript-promises-rejection/ http://thecodebarbarian.com/unhandled-promise-rejections-in-node.js.html https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch
PS: I think there's probably a way to make that code look cleaner
You have to await all those
this.bot.dig(...)
These articles should help you with Promise Rejections: https://flaviocopes.com/javascript-promises-rejection/ http://thecodebarbarian.com/unhandled-promise-rejections-in-node.js.html https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch
PS: I think there's probably a way to make that code look cleaner
Thank you, i'll try it. I'm start learn js only for mineflayer, not know too much, but i optimized it with array and for cycle
Close the issue if resolved.
Here's piece of my code `try{ if (this.bot.blockAt(v1.offset(1, 0, 0)).name != "air") { this.bot.dig(this.bot.blockAt(v1.offset(1, 0, 0)), false) await this.bot.waitForTicks(3) } if (this.bot.blockAt(v1.offset(1, 1, 0)).name != "air") { this.bot.dig(this.bot.blockAt(v1.offset(1, 1, 0)), false) await this.bot.waitForTicks(3) } if (this.bot.blockAt(v1.offset(1, 2, 0)).name != "air") { this.bot.dig(this.bot.blockAt(v1.offset(1, 2, 0)), false) await this.bot.waitForTicks(3) } if (this.bot.blockAt(v1.offset(1, 3, 0)).name != "air") { this.bot.dig(this.bot.blockAt(v1.offset(1, 3, 0)), false) await this.bot.waitForTicks(3) } if (this.bot.blockAt(v1.offset(0, 0, 1)).name != "air") { this.bot.dig(this.bot.blockAt(v1.offset(0, 0, 1)), false) await this.bot.waitForTicks(3) } if (this.bot.blockAt(v1.offset(0, 1, 1)).name != "air") { this.bot.dig(this.bot.blockAt(v1.offset(0, 1, 1)), false) await this.bot.waitForTicks(3) } if (this.bot.blockAt(v1.offset(0, 2, 1)).name != "air") { this.bot.dig(this.bot.blockAt(v1.offset(0, 2, 1)), false) await this.bot.waitForTicks(3) } if (this.bot.blockAt(v1.offset(0, 3, 1)).name != "air") { this.bot.dig(this.bot.blockAt(v1.offset(0, 3, 1)), false) await this.bot.waitForTicks(3) }
} catch (e) { console.log("qq") }`
Every time when i cant break block i get this error: diggingTask.cancel(new Error('Digging aborted')) ^
Error: Digging aborted at bot.stopDigging (C:\Users\vande\Desktop\Skyblock autofarm\Bots\node_modules\mineflayer\lib\plugins\digging.js:147:26) at EventEmitter.dig (C:\Users\vande\Desktop\Skyblock autofarm\Bots\node_modules\mineflayer\lib\plugins\digging.js:25:33) at Bot1.go (file:///C:/Users/vande/Desktop/Skyblock%20autofarm/Bots/bot1.mjs:94:34) at processTicksAndRejections (node:internal/process/task_queues:95:5) at runNextTicks (node:internal/process/task_queues:64:3) at process.processTimers (node:internal/timers:504:9)