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

TypeError when using realms in createBot #3587

Open
abic opened this issue Feb 16, 2025 · 0 comments
Open

TypeError when using realms in createBot #3587

abic opened this issue Feb 16, 2025 · 0 comments
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

@abic
Copy link

abic commented Feb 16, 2025

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

Versions

  • mineflayer: 4.26.0 (though I've hit the same issue for about 3 months)
  • server: Minecraft Realms
  • node: v22.12.0

Detailed description of a problem

Using a simple example code, attempting to connect to a local server with username and password does not result in any TypeErrors. Changing the example code to using realms with a pickRealms function results in a TypeError when loading the game.js plugin.

(node:39305) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
/path/to/project/node_modules/mineflayer/lib/plugins/game.js:87
  bot._client.registerChannel(brandChannel, ['string', []])
              ^

TypeError: bot._client.registerChannel is not a function
    at inject (/path/to/project/node_modules/mineflayer/lib/plugins/game.js:87:15)
    at /path/to/project/node_modules/mineflayer/lib/plugin_loader.js:41:7
    at Array.forEach (<anonymous>)
    at injectPlugins (/path/to/project/node_modules/mineflayer/lib/plugin_loader.js:40:16)
    at EventEmitter.onInjectAllowed (/path/to/project/node_modules/mineflayer/lib/plugin_loader.js:12:5)
    at Object.onceWrapper (node:events:638:28)
    at EventEmitter.emit (node:events:524:28)
    at Timeout._onTimeout (/path/to/project/node_modules/mineflayer/lib/loader.js:128:26)
    at listOnTimeout (node:internal/timers:594:17)
    at process.processTimers (node:internal/timers:529:7)

What did you try yet?

I tried a simple npm install mineflayer with the echo example code in README.md.
I then changed the createBot to use the realms option with pickRealms.

Your current code

const mineflayer = require('mineflayer')

const bot = mineflayer.createBot({
  username: 'EMAIL HIDDEN,
  auth: 'microsoft',
  realms: {
    pickRealm: (realms) => realms[0]
  }
})

bot.on('chat', (username, message) => {
  if (username === bot.username) return
  bot.chat(message)
})

// Log errors and kick reasons:
bot.on('kicked', console.log)
bot.on('error', console.log)

Expected behavior

A request to open a browser to authenticate to Microsoft for the Microsoft authentication for Realms.

Additional context

Add any other context about the problem here.

@abic abic 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 Feb 16, 2025
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

1 participant