PrismarineJS / mineflayer-collectblock

A simple utility plugin for Mineflayer that add a higher level API for collecting blocks.
MIT License
38 stars 23 forks source link

Promisify #73

Closed Saiv46 closed 2 years ago

Saiv46 commented 2 years ago

Callback is now optional, if omitted - methods returns promises.

Closes #41

rom1504 commented 2 years ago

Great Did you test it manually a bit to check it works ?

rom1504 commented 2 years ago

hey @Saiv46 ; I'd love to merge this so we can finish promisify migration of mineflayer, but I don't want to break this package can you please confirm things work after this change?

Saiv46 commented 2 years ago

hey @Saiv46 ; I'd love to merge this so we can finish promisify migration of mineflayer, but I don't want to break this package can you please confirm things work after this change?

I'm literally writing a bot just to use mineflayer-collectblock

rom1504 commented 2 years ago

Hey any news on this ? Let's get this promisify business done

rom1504 commented 2 years ago

@Saiv46 did you test it (manually) and does it work?

Saiv46 commented 2 years ago

@Saiv46 did you test it (manually) and does it work?

It works on my computer with non-LTS version of Node, I need someone else to test it (and possibly suggest changes).

rom1504 commented 2 years ago

maybe @ytcalifax ?

ytcalifax commented 2 years ago

maybe @ytcalifax ?

If there is a working build provided (if needed I could also 'npm run build' it myself) I could build it I could try testing it possibly, yeah. (I'm using Node v16.13.2)

rom1504 commented 2 years ago

yes you can just use this pr

ytcalifax commented 2 years ago

After building (via "npm install;npm run build"), installing the package locally into the bot and then running my mining command I get to this:


    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The last argument must be of type function. Received an instance of Object
    at collectCallbackified (node:util:300:5)
    at CollectBlock.<anonymous> (C:\Users\ytcalifax\Downloads\mineflayer-collectblock-promisify\lib\CollectBlock.js:175:61)
    at Generator.next (<anonymous>)
    at C:\Users\ytcalifax\Downloads\mineflayer-collectblock-promisify\lib\CollectBlock.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\ytcalifax\Downloads\mineflayer-collectblock-promisify\lib\CollectBlock.js:4:12)
    at CollectBlock.collect (C:\Users\ytcalifax\Downloads\mineflayer-collectblock-promisify\lib\CollectBlock.js:168:16)
    at collectBlocks (C:\Users\ytcalifax\Downloads\0Bot\index.js:75:22)
    at EventEmitter.<anonymous> (C:\Users\ytcalifax\Downloads\0Bot\index.js:47:19)
    at EventEmitter.emit (node:events:390:28) {
  code: 'ERR_INVALID_ARG_TYPE'
}
ytcalifax commented 2 years ago

The code I used to test was the same as the one in README, just called via a command.

rom1504 commented 2 years ago

You need to use a promise not a callback

I guess the example in the readme needs to be updated

On Tue, Feb 8, 2022, 14:39 ytcalifax @.***> wrote:

The code I used to test was the same as the one in README, just called via a command.

— Reply to this email directly, view it on GitHub https://github.com/PrismarineJS/mineflayer-collectblock/pull/73#issuecomment-1032620384, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAR437WXJWWDNKIK2LSBL63U2EMKRANCNFSM5HXVAB6A . You are receiving this because you commented.Message ID: @.***>

ytcalifax commented 2 years ago

Oops, yeah, my bad. I'll test it using promises as soon as I can.

Saiv46 commented 2 years ago

My bad, I tested with promises, but forgot about callbacks