Closed DUK-maybe closed 10 months ago
You should be await
'ing bot.dig() instead, the functions that "returns a Promise" can be await'ed so you can wait till the task completes. Please keep https://prismarinejs.github.io/mineflayer/#/api bookmarked.
Proper:
bot.on('chat' ,async(username, message) => {
if(message === "!note") {
await bot.dig(bot.blockAt(new Vec3(-10, 69, -78)));
}
})
You should be
await
'ing bot.dig() instead, the functions that "returns a Promise" can be await'ed so you can wait till the task completes. Please keep https://prismarinejs.github.io/mineflayer/#/api bookmarked.Proper:
bot.on('chat' ,async(username, message) => { if(message === "!note") { await bot.dig(bot.blockAt(new Vec3(-10, 69, -78))); } })
the code doesn't crash anymore but it is still digging,even i call bot.stopDigging()
Well how are you trying to stop it? .dig() will throw an error if you call stopDigging, so you'd need to dig().catch() it
bot.on('chat' ,async(username, message) => {
if(message === "!note") {
await bot.dig(bot.blockAt(new Vec3(-10, 69, -78)));
}
if(message === "!stop") {
bot.stopDigging();
}
})
Well how are you trying to stop it? .dig() will throw an error if you call stopDigging, so you'd need to dig().catch() it
bot.on('chat' ,async(username, message) => { if(message === "!note") { await bot.dig(bot.blockAt(new Vec3(-10, 69, -78))); } if(message === "!stop") { bot.stopDigging(); } })
the .catch() worked , thank you for helping me
Versions
Detailed description of a problem
i was trying to make the bot activate the noteblock without changing its tone (the bot.activateBlock change the noteblock sound) so i was thinking of digging the block and instantly stop digging, however the bot.stopDigging() make the code crash with the error
What did you try yet?
i searched other same issues with error code "digging aborted" but nothing helped Did you try any method from the API? Did you try any example? Any error from those?
Your current code
Expected behavior
It should not crash the code and the bot should stop digging PS:I am new to nodejs