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

"addChatPattern" not existing in mineflayer@4.9 but has not been stated that it has been removed #3245

Closed
1 task done
Myzumi opened this issue Dec 18, 2023 · 3 comments
Closed
1 task done
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@Myzumi
Copy link

Myzumi commented Dec 18, 2023

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.8.1 / 4.9
  • server: vanilla/spigot/unknown 1.8-1.20 (Hypixel)
  • node: 18.17.1

Detailed description of a problem

A clear and concise description of what the problem is, with as much context as possible.
What are you building? What problem are you trying to solve?

bot.addChatPattern does not existis anymore when upgrading to mineflayer@4.9 from 4.8.1
It has been tested with the latest version and with 4.10, 4.9, 4.8.1/4.8

What did you try yet?

Downgrading to find exact version that changes this.
This problem also persist in all versions above 4.9

Your current code

  const bot = await minecraft.createBot({
    auth: 'microsoft',
    username: process.env.GuildBotEmail,
    accessToken: process.env.GuildBotToken,
    //password: process.env.GuildBotPassword,
    chat: 'enabled',
    viewDistance: 1,
    version: "1.8.9",
    host: "hypixel.net",
  })

  bot.addChatPattern("in_limbo", /You were spawned in Limbo./)
  bot.addChatPattern("guild_chat", regex_guildchat, {parse: true})
  bot.addChatPattern("guild_join", /^Guild > ([\w\d]{2,17}).*? joined.*$/i, {parse: true})
  bot.addChatPattern("guild_left", /^Guild > ([\w\d]{2,17}).*? left.*$/i, {parse: true})
  bot.addChatPattern("guild_member_left", /^(\[.*?\])*.*? ([\w\d]{2,17}).*? left the Guild!*$/i, {parse: true})
  bot.addChatPattern("guild_member_join", /^(\[.*?\])*.*? ([\w\d]{2,17}).*? joined the Guild!*$/i, {parse: true})

most of the unrelated code has been removed and only relevant code is shown.

Expected behavior

A clear and concise description of what you expected to happen.
That bot.addChatPattern exists on the bot property in the version 4.9 and above as changelog does not state that it had been removed.

Additional context

Add any other context about the problem here.
image

@Myzumi Myzumi added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Dec 18, 2023
@extremeheat
Copy link
Member

This is because you are not waiting for the correct event. mineflayer requires you to wait for events like spawn before those functions become available.

@Myzumi
Copy link
Author

Myzumi commented Dec 24, 2023

This is because you are not waiting for the correct event. mineflayer requires you to wait for events like spawn before those functions become available.

Worked before without waiting for that event, so it was defently not mentioned in the changelog

@extremeheat
Copy link
Member

extremeheat commented Dec 24, 2023

It should not have been working if it did, as createBot() is not a synchronous call, it works asynchronously. As in the examples, all the mineflayer bot API methods (like this one) have to be called after the appropriate event, like connection to server, etc. Should be made clear in the API if not already. Feel free to do a PR to add that note to the api.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

2 participants