Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript does not account for event bot.on('goal_reached') #178

Closed
SinanAkkoyun opened this issue Jun 27, 2021 · 3 comments
Closed

Typescript does not account for event bot.on('goal_reached') #178

SinanAkkoyun opened this issue Jun 27, 2021 · 3 comments

Comments

@SinanAkkoyun
Copy link

The mineflayer bot events addition after doing loadPlugin do not play nicely with typescript types

await new Promise((resolve, reject) => {
                    this.bot.pathfinder.setGoal(new mineflayerPathfinder.goals.GoalXZ(pos.x, pos.z))
                    
                    this.bot.on('goal_reached', (goal: any) => {
                        resolve(goal)
                    })
                })

It tells me Argument of type '"goal_reached"' is not assignable to parameter of type 'keyof BotEvents'.ts(2345)

What can I do?

@SinanAkkoyun SinanAkkoyun changed the title Typescript event bot.on('goal_reached') Typescript does not account for event bot.on('goal_reached') Jun 27, 2021
@u9g
Copy link
Member

u9g commented Jun 27, 2021

as an alternative:

import { once } from 'events'
this.bot.pathfinder.setGoal(new mineflayerPathfinder.goals.GoalXZ(pos.x, pos.z))
await once(bot, 'goal_reached')

@SinanAkkoyun
Copy link
Author

Uhh, thank you very much, that's even better!

@SinanAkkoyun
Copy link
Author

What I actually was looking for:
await this.bot.pathfinder.goto(new mineflayerPathfinder.goals.GoalXZ(pos.x, pos.z))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants